Guest User

Untitled

a guest
May 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. longWorkTextBox.Text = "Ready For Work!";
  2. Action workAction = delegate
  3. {
  4. Console.WriteLine("Starting Work Action");
  5. int i = int.MaxValue;
  6. while (i > 0)
  7. i--;
  8. Console.WriteLine("Ending Work Action");
  9. longWorkTextBox.Text = "Work Complete";
  10. };
  11. longWorkTextBox.Dispatcher.BeginInvoke(DispatcherPriority.Background, workAction);
  12.  
  13. longWorkTextBox.Text = "Ready For Work!";
  14. Action workAction = delegate
  15. {
  16. BackgroundWorker worker = new BackgroundWorker();
  17. worker.DoWork += delegate
  18. {
  19. Console.WriteLine("Starting Slow Work");
  20. int i = int.MaxValue;
  21. while (i > 0)
  22. i--;
  23. Console.WriteLine("Ending Work Action");
  24. };
  25. worker.RunWorkerCompleted += delegate
  26. {
  27. longWorkTextBox.Text = "Work Complete";
  28. };
  29. worker.RunWorkerAsync();
  30. };
  31. longWorkTextBox.Dispatcher.BeginInvoke(DispatcherPriority.Background, workAction);
  32.  
  33. BackgroundWorker worker = new BackgroundWorker;
  34.  
  35. worker.WorkerReportsProgress = true;
  36. worker.WorkerSupportsCancellation = true;
  37. worker.DoWork +=new DoWorkEventHandler(worker_DoWork);
  38. worker.RunWorkerCompleted +=new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
  39. worker.ProgressChanged +=new ProgressChangedEventHandler(worker_ProgressChanged);
  40.  
  41. bkwkPlayingLoop.RunWorkerAsync();
Add Comment
Please, Sign In to add comment