Skip to content
代码片段 群组 项目
未验证 提交 cf77999a 编辑于 作者: Kahbazi's avatar Kahbazi 提交者: GitHub
浏览文件

Dispost CancellationTokenSource in WebHostExtensions (#23969)

上级 cee763b1
No related branches found
No related tags found
无相关合并请求
...@@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Hosting ...@@ -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 ...@@ -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>
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册