BackgroundService 类

定义

用于实现长时间运行的 IHostedService 的基类。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
继承
BackgroundService
实现

构造函数

BackgroundService()

方法

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.

(继承自 Object)
ExecuteAsync(CancellationToken)

此方法在启动 IHostedService 时调用。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.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 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.

(继承自 Object)

适用于