Anyone have example C# using QueuedTask.UIScheduler?

10-09-2020 03:19 PM
New Contributor II

Anyone have example C# using QueuedTask.UIScheduler? I have a lot of code that is running in worker thread using QueuedTask.Run but need to somehow dispatch a call to update the gui in the middle of it all. Any examples using UIScheduler or C# .Net would be great.

0 Kudos
2 Replies
Community Moderator

Hi Arwen, 

Maybe somebody in the ArcGIS Pro SDK‌ group could help...  

Esri Regular Contributor


You can use BeginInvoke to execute on the UI thread.

    private void onLayersAddRem(LayerEventsArgs obj)
//regenerate snaplist when layers are added or removed
//run on UI Thread to sync layersadded event (which runs on background)
System.Windows.Application.Current.Dispatcher.BeginInvoke((Action)(() => { PopulateSnapList(); }));

In this example I am updating a datagrid in a dockpane from the background thread.

See also: How to use BeginInvoke C# - Stack Overflow