Skip to content

Commit 4faa84c

Browse files
Write manual Parallel.For to await test result (#44528)
1 parent 85ba834 commit 4faa84c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Servers/Kestrel/test/InMemory.FunctionalTests/RequestTests.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,12 +604,17 @@ public async Task TraceIdentifierIsUnique()
604604
var usedIds = new ConcurrentBag<string>();
605605

606606
// requests on separate connections in parallel
607-
Parallel.For(0, iterations, async i =>
607+
var tasks = new List<Task>(iterations);
608+
for (var i = 0; i < iterations; i++)
608609
{
609-
var id = await server.HttpClientSlim.GetStringAsync($"http://localhost:{server.Port}/");
610-
Assert.DoesNotContain(id, usedIds.ToArray());
611-
usedIds.Add(id);
612-
});
610+
tasks.Add(Task.Run(async () =>
611+
{
612+
var id = await server.HttpClientSlim.GetStringAsync($"http://localhost:{server.Port}/");
613+
Assert.DoesNotContain(id, usedIds.ToArray());
614+
usedIds.Add(id);
615+
}));
616+
}
617+
await Task.WhenAll(tasks);
613618

614619
// requests on same connection
615620
using (var connection = server.CreateConnection())

0 commit comments

Comments
 (0)