We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d755e2 commit ed86689Copy full SHA for ed86689
test/PowerShellEditorServices.Test/Language/LanguageServiceTests.cs
@@ -420,12 +420,12 @@ internal static class TaskExtensions
420
{
421
public static async Task<T> RunWithTimeout<T>(this Task<T> task, int timeoutMillis = 10000)
422
423
- if (await Task.WhenAny(task, Task.Delay(timeoutMillis)) == task)
+ Task<T> newThreadTask = Task<T>.Run(() => task);
424
+ if (!((IAsyncResult)newThreadTask).AsyncWaitHandle.WaitOne(timeoutMillis))
425
- return task.Result;
426
+ throw new TimeoutException();
427
}
-
428
- throw new TimeoutException();
+ return await newThreadTask;
429
430
431
0 commit comments