From b4d91d4a4b2f1913d2a03f107fc66f49dc82849a Mon Sep 17 00:00:00 2001 From: Jared Parsons Date: Sun, 25 Oct 2015 08:02:08 -0700 Subject: [PATCH] Actually delete PumpingWait Now that the internal dependencies have been removed we can delete the PumpingWait methods. --- .../TestUtilities/Async/WaitHelper.cs | 57 ------------------- .../Diagnostics/TestingOnly_WaitingService.cs | 5 -- 2 files changed, 62 deletions(-) diff --git a/src/EditorFeatures/TestUtilities/Async/WaitHelper.cs b/src/EditorFeatures/TestUtilities/Async/WaitHelper.cs index 6eb140de239..ffa3a2c769f 100644 --- a/src/EditorFeatures/TestUtilities/Async/WaitHelper.cs +++ b/src/EditorFeatures/TestUtilities/Async/WaitHelper.cs @@ -13,67 +13,10 @@ namespace Roslyn.Test.Utilities { public static class WaitHelper { - /// - /// This is a hueristic for checking to see if we are in a deadlock state because - /// we are waiting on a Task that may be in the StaTaskScheduler queue from the - /// main thread. - /// - /// - private static void CheckForStaDeadlockInPumpingWait(IEnumerable tasks) - { - var sta = StaTaskScheduler.DefaultSta; - Debug.Assert(sta.Threads.Length == 1); - - if (Thread.CurrentThread != sta.Threads[0]) - { - return; - } - - if (tasks.Any(x => x.Status == TaskStatus.WaitingForActivation) && sta.IsAnyQueued()) - { - throw new InvalidOperationException("PumingWait is likely in a deadlock"); - } - } - public static void WaitForDispatchedOperationsToComplete(DispatcherPriority priority) { Action action = delegate { }; new FrameworkElement().Dispatcher.Invoke(action, priority); } - - public static void PumpingWait(this Task task) - { - PumpingWaitAll(new[] { task }); - } - - public static T PumpingWaitResult(this Task task) - { - PumpingWait(task); - return task.Result; - } - - public static void PumpingWaitAll(this IEnumerable tasks) - { - var smallTimeout = TimeSpan.FromMilliseconds(10); - var taskArray = tasks.ToArray(); - var done = false; - while (!done) - { - done = Task.WaitAll(taskArray, smallTimeout); - if (!done) - { - WaitForDispatchedOperationsToComplete(DispatcherPriority.ApplicationIdle); - CheckForStaDeadlockInPumpingWait(tasks); - } - } - - foreach (var task in tasks) - { - if (task.Exception != null) - { - throw task.Exception; - } - } - } } } \ No newline at end of file diff --git a/src/Test/Diagnostics/TestingOnly_WaitingService.cs b/src/Test/Diagnostics/TestingOnly_WaitingService.cs index 6354a9a2a8b..50e6e974f9d 100644 --- a/src/Test/Diagnostics/TestingOnly_WaitingService.cs +++ b/src/Test/Diagnostics/TestingOnly_WaitingService.cs @@ -118,10 +118,5 @@ public void EnableActiveTokenTracking(bool enable) waiter.Value.TrackActiveTokens = enable; } } - - public void PumpingWait(Task task) - { - task.PumpingWait(); - } } } -- GitLab