// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.ServiceProcess;
namespace Microsoft.AspNetCore.Hosting.WindowsServices
{
///
/// Extensions to for hosting inside a Windows service.
///
public static class WebHostWindowsServiceExtensions
{
///
/// Runs the specified web application inside a Windows service and blocks until the service is stopped.
///
/// An instance of the to host in the Windows service.
///
/// This example shows how to use .
///
/// public class Program
/// {
/// public static void Main(string[] args)
/// {
/// var config = WebHostConfiguration.GetDefault(args);
///
/// var host = new WebHostBuilder()
/// .UseConfiguration(config)
/// .Build();
///
/// // This call will block until the service is stopped.
/// host.RunAsService();
/// }
/// }
///
///
public static void RunAsService(this IWebHost host)
{
var webHostService = new WebHostService(host);
ServiceBase.Run(webHostService);
}
}
}