Add ConfigureAwait to prevent xunit hangs

This commit is contained in:
Chris R 2017-04-13 07:46:51 -07:00
parent 62f74d5be0
commit a8c61b5abc
1 changed files with 5 additions and 2 deletions

View File

@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
var diagnosticSource = _applicationServices.GetRequiredService<DiagnosticListener>();
var httpContextFactory = _applicationServices.GetRequiredService<IHttpContextFactory>();
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();