From b5538fee94259ab840a6e44fd9231c1ef8fc402a Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 19 Apr 2021 09:50:40 -0500 Subject: [PATCH] Update HostTests.cs --- .../tests/UnitTests/Internal/HostTests.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs b/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs index 4138e7df4c5c08..dd8e96507f3bba 100644 --- a/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs +++ b/src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs @@ -710,11 +710,12 @@ public async Task HostStopsApplicationWithOneBackgroundServiceErrorAndOthersWith var wasStoppingCalled = false; lifetime.ApplicationStopping.Register(() => { - otherTcs.SetResult(true); wasStoppingCalled = true; + otherTcs.SetResult(true); }); - await host.StartAsync(); + // Ensure all completions have been signaled before continuing + await Task.WhenAll(host.StartAsync(), throwingTcs.Task, otherTcs.Task); Assert.True(wasStartedCalled); Assert.True(wasStoppingCalled);