Dispost CancellationTokenSource in WebHostExtensions (#23969)
This commit is contained in:
parent
cee763b189
commit
cf77999a3b
|
|
@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
public static void Run(this Microsoft.AspNetCore.Hosting.IWebHost host) { }
|
public static void Run(this Microsoft.AspNetCore.Hosting.IWebHost host) { }
|
||||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
[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; }
|
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 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) { }
|
public static void WaitForShutdown(this Microsoft.AspNetCore.Hosting.IWebHost host) { }
|
||||||
[System.Diagnostics.DebuggerStepThroughAttribute]
|
[System.Diagnostics.DebuggerStepThroughAttribute]
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
/// <param name="timeout">The timeout for stopping gracefully. Once expired the
|
/// <param name="timeout">The timeout for stopping gracefully. Once expired the
|
||||||
/// server may terminate any remaining active connections.</param>
|
/// server may terminate any remaining active connections.</param>
|
||||||
/// <returns>A <see cref="Task"/> that completes when the <see cref="IWebHost"/> stops.</returns>
|
/// <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>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue