Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 0.44 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Update UI Label when using Task.Factory.StartNew
  2. Task.Factory.StartNew( () => RecurseAndDeleteStart() );
  3.        
  4. // This line needs to happen on the UI thread...
  5. TaskScheduler uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
  6.  
  7. Task.Factory.StartNew( () => RecurseAndDeleteStart(uiScheduler) );
  8.        
  9. Task.Factory.StartNew( () =>
  10.   {
  11.       theLabel.Text = "Foo";
  12.   }, CancellationToken.None, TaskCreationOptions.None, uiScheduler);