Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. static void RebuildTests ()
  2. {
  3. throttling.Cancel ();
  4. throttling = new CancellationTokenSource ();
  5. Task.Delay (ThrottlingTimeout, throttling.Token).ContinueWith (async (task) => {
  6. if (task.IsCanceled)
  7. return;
  8. try {
  9. if (rootTests != null) {
  10. foreach (IDisposable t in rootTests)
  11. t.Dispose ();
  12. }
  13. List<UnitTest> list = new List<UnitTest> ();
  14. rebuildTestsCts.Cancel ();
  15. rebuildTestsCts = new CancellationTokenSource ();
  16. var token = rebuildTestsCts.Token;
  17. var items = IdeApp.Workspace.Items.ToArray ();
  18. await Task.Run (() => {
  19. foreach (WorkspaceItem it in items) {
  20. if (token.IsCancellationRequested)
  21. return;
  22. UnitTest t = BuildTest (it);
  23. if (t != null)
  24. list.Add (t);
  25. }
  26. }, token);
  27. if (token.IsCancellationRequested)
  28. return;
  29. rootTests = list.ToArray ();
  30. NotifyTestSuiteChanged ();
  31. } catch (OperationCanceledException) {
  32. } catch (Exception ex) {
  33. LoggingService.LogError ("Exception gathering unit tests.", ex);
  34. }
  35. }, throttling.Token, TaskContinuationOptions.None, Runtime.MainTaskScheduler);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement