From 43c30d8045703e89fafe60325c279f2e0c1c91a5 Mon Sep 17 00:00:00 2001 From: madelson <1269046+madelson@users.noreply.github.com> Date: Wed, 24 May 2023 16:38:16 -0400 Subject: [PATCH] Fix timeouts in resourcemanager test (#86680) * Update BinaryResourceWriterUnitTest.cs Apply suggestion from https://github.com/dotnet/runtime/issues/86013#issuecomment-1560231543 Co-authored-by: Buyaa Namnan --- .../tests/BinaryResourceWriterUnitTest.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Resources.Extensions/tests/BinaryResourceWriterUnitTest.cs b/src/libraries/System.Resources.Extensions/tests/BinaryResourceWriterUnitTest.cs index 21accbc..848d5a9 100644 --- a/src/libraries/System.Resources.Extensions/tests/BinaryResourceWriterUnitTest.cs +++ b/src/libraries/System.Resources.Extensions/tests/BinaryResourceWriterUnitTest.cs @@ -526,9 +526,15 @@ namespace System.Resources.Extensions.Tests const int Threads = 10; using Barrier barrier = new(Threads); - Task task = Task.WhenAll(Enumerable.Range(0, Threads).Select(_ => Task.Run(WaitForBarrierThenEnumerateResources))); - - Assert.True(task.Wait(TimeSpan.FromSeconds(30))); + Task[] tasks = Enumerable.Range(0, Threads) + .Select(_ => Task.Factory.StartNew( + WaitForBarrierThenEnumerateResources, + CancellationToken.None, + TaskCreationOptions.LongRunning, + TaskScheduler.Default)) + .ToArray(); + + Assert.True(Task.WaitAll(tasks, TimeSpan.FromSeconds(30))); void WaitForBarrierThenEnumerateResources() { -- 2.7.4