Killing a Worker Application from a BackgroundService

Download full source code. If you have an application that runs a BackgroundService or maybe a few BackgroundService s, you may want to stop the host application and all the other services from one of the BackgroundService s . The first approach I tried was to pass a CancellationTokenSource to the service using dependency injection and then call Cancel() on it. The host application monitors the…