Is the internal implementation of the library supplying me with a cancellation token source, or do I need to create my own?
I'm reading the documentation and it seems like I would need to create my own source in the caller method, then pass the token to the service.
No, you will not be getting
CancellationTokenSource, onlyCancelationToken's forStartAsync/StopAsyncmethods (to support graceful shutdown/interruption, some docs).If need to cancel call to some service additionally you will need to create your own
CancellationTokenSourceviaCancellationTokenSource.CreateLinkedTokenSource. Something along these lines:If you don't have custom cancellation logic then using passed
cancellationTokenis enough.Also consider using
BackgroundServicebase class, it encapsulates some of usual hosted service boilerplate code.