From a8c61b5abccfbce28f1aa21dd967462c7d3bf0ca Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 13 Apr 2017 07:46:51 -0700 Subject: [PATCH] Add ConfigureAwait to prevent xunit hangs --- src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs index d09620344f..5d08a6fec7 100644 --- a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs +++ b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs @@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal var diagnosticSource = _applicationServices.GetRequiredService(); var httpContextFactory = _applicationServices.GetRequiredService(); var hostingApp = new HostingApplication(_application, _logger, diagnosticSource, httpContextFactory); - await Server.StartAsync(hostingApp, cancellationToken); + await Server.StartAsync(hostingApp, cancellationToken).ConfigureAwait(false); // Fire IApplicationLifetime.Started _applicationLifetime?.NotifyStarted(); @@ -290,7 +290,10 @@ namespace Microsoft.AspNetCore.Hosting.Internal // Fire IApplicationLifetime.Stopping _applicationLifetime?.StopApplication(); - await Server?.StopAsync(cancellationToken); + if (Server != null) + { + await Server.StopAsync(cancellationToken).ConfigureAwait(false); + } // Fire the IHostedService.Stop _hostedServiceExecutor?.Stop();