diff --git a/src/EditorFeatures/TestUtilities/Async/WaitHelper.cs b/src/EditorFeatures/TestUtilities/Async/WaitHelper.cs index 6eb140de239f15866e0a94590eb3286775f5e225..ffa3a2c769f7074e71dfc418ac43e084950548ed 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 6354a9a2a8b58a8835c03f80778fcdd1b441cbf7..50e6e974f9dd014af1775ea746b68ba2b53f77b8 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(); - } } }