This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Base class for implementing a long runningIHostedService.
public ref class BackgroundService abstract : IDisposable, Microsoft::Extensions::Hosting::IHostedServicepublic abstract class BackgroundService : IDisposable, Microsoft.Extensions.Hosting.IHostedServicetype BackgroundService = class interface IHostedService interface IDisposablePublic MustInherit Class BackgroundServiceImplements IDisposable, IHostedService| Name | Description |
|---|---|
| BackgroundService() | Initializes a new instance of theBackgroundService class. |
| Name | Description |
|---|---|
| ExecuteTask | Gets the Task that executes the background operation. |
| Name | Description |
|---|---|
| Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
| ExecuteAsync(CancellationToken) | This method is called when theIHostedService starts. The implementation should return a task that representsthe lifetime of the long running operation(s) being performed. |
| StartAsync(CancellationToken) | Triggered when the application host is ready to start the service. |
| StopAsync(CancellationToken) | Triggered when the application host is performing a graceful shutdown. |
| Name | Description |
|---|---|
| StartAndStopAsync(IHostedService, CancellationToken) | Starts and immediately stops the service. |
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?