Bagikan melalui


WebHostWindowsServiceExtensions.RunAsService(IWebHost) Metode

Definisi

Menjalankan aplikasi web yang ditentukan di dalam layanan Windows dan memblokir hingga layanan dihentikan.

public:
[System::Runtime::CompilerServices::Extension]
 static void RunAsService(Microsoft::AspNetCore::Hosting::IWebHost ^ host);
public static void RunAsService (this Microsoft.AspNetCore.Hosting.IWebHost host);
static member RunAsService : Microsoft.AspNetCore.Hosting.IWebHost -> unit
<Extension()>
Public Sub RunAsService (host As IWebHost)

Parameter

host
IWebHost

Instans untuk menghosting IWebHost di layanan Windows.

Contoh

Contoh ini menunjukkan cara menggunakan RunAsService(IWebHost).

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();
    }
}

Berlaku untuk