Class ConsoleHostedService<TStartup>
- Namespace
- Codebelt.Bootstrapper.Console
- Assembly
- Codebelt.Bootstrapper.Console.dll
Provides a console application that is managed by its host.
public class ConsoleHostedService<TStartup> : IHostedService where TStartup : ConsoleStartup
Type Parameters
TStartup
The type containing the startup methods for the application.
- Inheritance
-
ConsoleHostedService<TStartup>
- Implements
Constructors
ConsoleHostedService(IStartupFactory<TStartup>, IHostApplicationLifetime, IServiceProvider, IHostLifetimeEvents)
Initializes a new instance of the ConsoleHostedService<TStartup> class.
public ConsoleHostedService(IStartupFactory<TStartup> factory, IHostApplicationLifetime applicationLifetime, IServiceProvider provider, IHostLifetimeEvents events)
Parameters
factory
IStartupFactory<TStartup>The dependency injected IStartupFactory<TStartup>.
applicationLifetime
IHostApplicationLifetimeThe dependency injected IHostApplicationLifetime.
provider
IServiceProviderThe dependency injected IServiceProvider.
events
IHostLifetimeEventsThe dependency injected IHostLifetimeEvents.
Methods
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenIndicates that the start process has been aborted.
Returns
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenIndicates that the shutdown process should no longer be graceful.