src/packages/EmbedIO/WebServerExtensions.cs
/// <summary>
/// Starts a web server by calling <see cref="IWebServer.RunAsync"/>
/// in another thread.
/// </summary>
/// <param name="this">The <see cref="IWebServer"/> on which this method is called.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> used to stop the web server.</param>
/// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
/// <exception cref="InvalidOperationException">The web server has already been started.</exception>
Starts a web server by calling
in another thread.
Starts a web server by calling in another thread .
public static void Start(this IWebServer @this, CancellationToken cancellationToken = default)
        {
#pragma warning disable CS4014 
            Task.Run(() => @this.RunAsync(cancellationToken));
#pragma warning restore CS4014
            while (@this.State < WebServerState.Listening)
                Task.Delay(1, cancellationToken).Await();
        }
public static void Start ( this IWebServer @this , CancellationToken cancellationToken = default ) { pragma warning disable CS4014 Task . Run ( ( ) => @this . RunAsync ( cancellationToken ) ) ; pragma warning restore CS4014 while ( @this . State < WebServerState . Listening ) Task . Delay ( 1 , cancellationToken ) . Await ( ) ; }
Starts a web server by calling
in another thread.
Starts a web server by calling in another thread .
// The call is not awaited - it is expected to run in parallel.
None
The web server has already been started.
The web server has already been started .
IWebServer
this
cancellationToken
CancellationToken
A  used to stop the web server.
A used to stop the web server .
this
The  on which this method is called.
The on which this method is called .