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.
Arwen,
You can use BeginInvoke to execute on the UI thread.
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">onLayersAddRem</SPAN><SPAN class="punctuation token">(</SPAN>LayerEventsArgs obj<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">//regenerate snaplist when layers are added or removed</SPAN> <SPAN class="comment token">//run on UI Thread to sync layersadded event (which runs on background)</SPAN> System<SPAN class="punctuation token">.</SPAN>Windows<SPAN class="punctuation token">.</SPAN>Application<SPAN class="punctuation token">.</SPAN>Current<SPAN class="punctuation token">.</SPAN>Dispatcher<SPAN class="punctuation token">.</SPAN><SPAN class="token function">BeginInvoke</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>Action<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="token function">PopulateSnapList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
In this example I am updating a datagrid in a dockpane from the background thread.
See also: How to use BeginInvoke C# - Stack Overflow
Hi Arwen,
Maybe somebody in the ArcGIS Pro SDK group could help...
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.