diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs b/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs
index b1202d9405..79b7829728 100644
--- a/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs
+++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/IWebHost.cs
@@ -26,13 +26,18 @@ namespace Microsoft.AspNetCore.Hosting
///
/// Starts listening on the configured addresses.
///
- Task StartAsync(CancellationToken cancellationToken);
+ void Start();
+
+ ///
+ /// Starts listening on the configured addresses.
+ ///
+ Task StartAsync(CancellationToken cancellationToken = default(CancellationToken));
///
/// Attempt to gracefully stop the host.
///
///
///
- Task StopAsync(CancellationToken cancellationToken);
+ Task StopAsync(CancellationToken cancellationToken = default(CancellationToken));
}
}
diff --git a/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json
index e523c48473..10b35b470d 100644
--- a/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json
+++ b/src/Microsoft.AspNetCore.Hosting.Abstractions/breakingchanges.netcore.json
@@ -1,9 +1,4 @@
[
- {
- "TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHost : System.IDisposable",
- "MemberId": "System.Void Start()",
- "Kind": "Removal"
- },
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHostBuilder",
"MemberId": "Microsoft.AspNetCore.Hosting.IWebHostBuilder ConfigureAppConfiguration(System.Action configureDelegate)",
@@ -16,12 +11,12 @@
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHost : System.IDisposable",
- "MemberId": "System.Threading.Tasks.Task StartAsync(System.Threading.CancellationToken cancellationToken)",
+ "MemberId": "System.Threading.Tasks.Task StartAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))",
"Kind": "Addition"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Hosting.IWebHost : System.IDisposable",
- "MemberId": "System.Threading.Tasks.Task StopAsync(System.Threading.CancellationToken cancellationToken)",
+ "MemberId": "System.Threading.Tasks.Task StopAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))",
"Kind": "Addition"
},
{
diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs
index d4e7c09cd6..09f159a642 100644
--- a/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs
+++ b/src/Microsoft.AspNetCore.Hosting/Internal/WebHost.cs
@@ -104,7 +104,12 @@ namespace Microsoft.AspNetCore.Hosting.Internal
}
}
- public virtual async Task StartAsync(CancellationToken cancellationToken)
+ public void Start()
+ {
+ StartAsync().GetAwaiter().GetResult();
+ }
+
+ public virtual async Task StartAsync(CancellationToken cancellationToken = default(CancellationToken))
{
HostingEventSource.Log.HostStart();
_logger = _applicationServices.GetRequiredService>();
@@ -267,7 +272,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
}
}
- public async Task StopAsync(CancellationToken cancellationToken)
+ public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken))
{
if (_stopped)
{
@@ -313,7 +318,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
{
try
{
- this.StopAsync().GetAwaiter().GetResult();
+ StopAsync().GetAwaiter().GetResult();
}
catch (Exception ex)
{
diff --git a/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs b/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs
index 0689b9f252..3dcd322602 100644
--- a/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs
+++ b/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting.Server.Features;
@@ -12,36 +11,6 @@ namespace Microsoft.AspNetCore.Hosting
{
public static class WebHostExtensions
{
- ///
- /// Starts the host.
- ///
- ///
- ///
- public static void Start(this IWebHost host)
- {
- host.StartAsync().GetAwaiter().GetResult();
- }
-
- ///
- /// Starts the host.
- ///
- ///
- ///
- public static Task StartAsync(this IWebHost host)
- {
- return host.StartAsync(CancellationToken.None);
- }
-
- ///
- /// Gracefully stops the host.
- ///
- ///
- ///
- public static Task StopAsync(this IWebHost host)
- {
- return host.StopAsync(CancellationToken.None);
- }
-
///
/// Attempts to gracefully stop the host with the given timeout.
///