Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b50520e

Browse files
committed
Fix failing TaskWaitAllAny* tests
Some of these tests have been failing in CI. While unwieldy in general, the specific issue is that when the tests are shutting down, they cancel any tasks that haven't yet completed, but then simply wait on the tasks to complete. If the task hadn't yet started, the cancellation request would cause the task to end as Canceled, which would cause the Wait to throw. The fix is simply to catch and ignore the resulting OperationCanceledException.
1 parent 18ccd53 commit b50520e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/System.Threading.Tasks/tests/Task/TaskWaitAllAnyTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ private void CleanUpTasks()
294294
if (taskInfo.Task.Status == TaskStatus.Running)
295295
{
296296
taskInfo.CancellationTokenSource.Cancel();
297-
taskInfo.Task.Wait();
297+
try { taskInfo.Task.GetAwaiter().GetResult(); }
298+
catch (OperationCanceledException) { }
298299
}
299300
}
300301
}

0 commit comments

Comments
 (0)