Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class Microsoft.​Extensions.​Hosting.​HostingAbstractionsHostExtensions

Assembly: Microsoft.Extensions.Hosting.Abstractions

Inheritance: object → HostingAbstractionsHostExtensions

Provides extension methods for the <see cref="T:Microsoft.Extensions.Hosting.IHost" /> from the hosting abstractions package.

Methods

public static void
Run​(IHost host)
Runs an application and blocks the calling thread until host shutdown is triggered and all <see cref="T:Microsoft.Extensions.Hosting.IHostedService" /> instances are stopped.
host The <see cref="T:Microsoft.Extensions.Hosting.IHost" /> to run.
RunAsync​(IHost host, System.​Threading.​CancellationToken token = null)
Runs an application and returns a <see cref="T:System.Threading.Tasks.Task" /> that only completes when the token is triggered or shutdown is triggered. The <paramref name="host" /> instance is disposed of after running.
Returns The <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation.
host The <see cref="T:Microsoft.Extensions.Hosting.IHost" /> to run.
token The token to trigger shutdown.
public static void
Start​(IHost host)
Starts the host synchronously.
host The <see cref="T:Microsoft.Extensions.Hosting.IHost" /> to start.
StopAsync​(IHost host, System.​TimeSpan timeout)
Attempts to gracefully stop the host with the given timeout.
Returns The <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation.
host The <see cref="T:Microsoft.Extensions.Hosting.IHost" /> to stop.
timeout The timeout for stopping gracefully. Once expired the server may terminate any remaining active connections.
public static void
WaitForShutdown​(IHost host)
Blocks the calling thread until shutdown is triggered via Ctrl+C or SIGTERM.
host The running <see cref="T:Microsoft.Extensions.Hosting.IHost" /> .
WaitForShutdownAsync​(IHost host, System.​Threading.​CancellationToken token = null)
Returns a Task that completes when shutdown is triggered via the given token.
Returns The <see cref="T:System.Threading.Tasks.Task" /> that represents the asynchronous operation.
host The running <see cref="T:Microsoft.Extensions.Hosting.IHost" /> .
token The token to trigger shutdown.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object