dotnetcore-windows-linux-service icon indicating copy to clipboard operation
dotnetcore-windows-linux-service copied to clipboard

Keeping everything in one project vs 3

Open mostwired opened this issue 5 years ago • 1 comments

Hi Dejan,

Got a question - with System.ServiceProcess referenced and ServiceBase.Run() code used, the project publishes OK to Linux. If, instead of having separate projects for win/linux, one would check the OS and execute ServiceBase.Run() only on Windows, while using RunAsync() on Linux - what would be the downside of doing it this way?

mostwired avatar Apr 06 '19 17:04 mostwired

Hi, with ServiceBase.Run() you can only run service on Windows because ServiceBase is aware of service stop event on Windows. On Linux you have to use AppHost to be aware of stopping of the service and do your clean exit

dejanstojanovic avatar Apr 07 '19 04:04 dejanstojanovic