Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.53 KB  |  views: 36  |  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. C# - How to change value of a progress bar in a secondary thread
  2. .......
  3. bulkCopy.NotifyAfter = 2000;
  4. bulkCopy.SqlRowsCopied += new SqlRowsCopiedEventHandler(bulkCopy_SqlRowsCopied);
  5. .......
  6.        
  7. public static class ControlExtensions
  8. {
  9.     public static void Invoke(this Control control, Action action)
  10.     {
  11.         if (control.InvokeRequired) control.Invoke(new MethodInvoker(action), null);
  12.         else action.Invoke();
  13.     }
  14.  }
  15.        
  16. progressBar.Invoke(() => { progressBar.PerformStep(); };
  17.        
  18. Task.Factory.StartNew(MyBulkCopyMethod);
clone this paste RAW Paste Data