Anyone have example C# using QueuedTask.UIScheduler?

814
2
10-09-2020 03:19 PM
ArwenVaughan1
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
KoryKramer
Esri Community Moderator

Hi Arwen, 

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

by Anonymous User
Not applicable

Arwen,

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