diff --git a/src/Hosting/Hosting/ref/Microsoft.AspNetCore.Hosting.netcoreapp.cs b/src/Hosting/Hosting/ref/Microsoft.AspNetCore.Hosting.netcoreapp.cs index b87c115deade68f77c8158c6b085f1cf551c782e..0ed621abe17073c501168147d962788b723e86c4 100644 --- a/src/Hosting/Hosting/ref/Microsoft.AspNetCore.Hosting.netcoreapp.cs +++ b/src/Hosting/Hosting/ref/Microsoft.AspNetCore.Hosting.netcoreapp.cs @@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Hosting public static void Run(this Microsoft.AspNetCore.Hosting.IWebHost host) { } [System.Diagnostics.DebuggerStepThroughAttribute] public static System.Threading.Tasks.Task RunAsync(this Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) { throw null; } + [System.Diagnostics.DebuggerStepThroughAttribute] public static System.Threading.Tasks.Task StopAsync(this Microsoft.AspNetCore.Hosting.IWebHost host, System.TimeSpan timeout) { throw null; } public static void WaitForShutdown(this Microsoft.AspNetCore.Hosting.IWebHost host) { } [System.Diagnostics.DebuggerStepThroughAttribute] diff --git a/src/Hosting/Hosting/src/WebHostExtensions.cs b/src/Hosting/Hosting/src/WebHostExtensions.cs index b1b317272bc9df88c47b9545fb4633f647f798b3..fe77b134432e8b6cc5f74721259c0f934645b16b 100644 --- a/src/Hosting/Hosting/src/WebHostExtensions.cs +++ b/src/Hosting/Hosting/src/WebHostExtensions.cs @@ -19,9 +19,10 @@ namespace Microsoft.AspNetCore.Hosting /// <param name="timeout">The timeout for stopping gracefully. Once expired the /// server may terminate any remaining active connections.</param> /// <returns>A <see cref="Task"/> that completes when the <see cref="IWebHost"/> stops.</returns> - public static Task StopAsync(this IWebHost host, TimeSpan timeout) + public static async Task StopAsync(this IWebHost host, TimeSpan timeout) { - return host.StopAsync(new CancellationTokenSource(timeout).Token); + using var cts = new CancellationTokenSource(timeout); + await host.StopAsync(cts.Token); } /// <summary>