using System;
using System.Threading;
using System.Threading.Tasks;
using Swan;
namespace EmbedIO
{
///
/// Provides extension methods for types implementing .
///
public static partial class WebServerExtensions
{
///
/// Starts a web server by calling
/// in another thread.
///
/// The on which this method is called.
/// A used to stop the web server.
/// is .
/// The web server has already been started.
public static void Start(this IWebServer @this, CancellationToken cancellationToken = default)
{
#pragma warning disable CS4014 // The call is not awaited - it is expected to run in parallel.
Task.Run(() => @this.RunAsync(cancellationToken));
#pragma warning restore CS4014
while (@this.State < WebServerState.Listening)
Task.Delay(1, cancellationToken).Await();
}
}
}