Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

BackgroundService Class

Definition

Namespace:
Microsoft.Extensions.Hosting
Assembly:
Microsoft.Extensions.Hosting.Abstractions.dll
Package:
Microsoft.Extensions.Hosting.Abstractions v11.0.0-preview.5.26302.115
Source:
BackgroundService.cs
Source:
BackgroundService.cs
Source:
BackgroundService.cs
Source:
BackgroundService.cs

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 running IHostedService.

public ref class BackgroundService abstract : IDisposable, Microsoft::Extensions::Hosting::IHostedService
public abstract class BackgroundService : IDisposable, Microsoft.Extensions.Hosting.IHostedService
type BackgroundService = class
 interface IHostedService
 interface IDisposable
Public MustInherit Class BackgroundService
Implements IDisposable, IHostedService
Inheritance
BackgroundService
Implements

Constructors

Name Description
BackgroundService()

Initializes a new instance of the BackgroundService class.

Properties

Name Description
ExecuteTask

Gets the Task that executes the background operation.

Methods

Name Description
Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
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.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Extension Methods

Name Description
StartAndStopAsync(IHostedService, CancellationToken)

Starts and immediately stops the service.

Applies to


Feedback

Was this page helpful?