aspnet / Hosting

[Archived] Code for hosting and starting up an ASP.NET Core application. Project moved to https://github.com/aspnet/Extensions and https://github.com/aspnet/AspNetCore
Apache License 2.0
552 stars 312 forks source link

Microsoft.AspNetCore.Hosting.WindowsServices RunAsServiceAsync #1600

Closed bugproof closed 5 years ago

bugproof commented 5 years ago

I'm using C# 7.1 async Task Main(string[] args). I wanted to convert my project into a Windows Service following this: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.1

In my Program.Main I'm using await webHost.RunAsync();. I was hoping to have something like await webHost.RunAsServiceAsync(). What should I do?

Tratcher commented 5 years ago

ServiceBase Run isn't async, there's nothing to do here. https://github.com/aspnet/Hosting/blob/f9d145887773e0c650e66165e0c61886153bcc0b/src/Microsoft.AspNetCore.Hosting.WindowsServices/WebHostWindowsServiceExtensions.cs#L38-L39