WindowsServiceLifetime 类

定义

侦听关闭信号并跟踪 Windows 服务的状态。

public ref class WindowsServiceLifetime : System::ServiceProcess::ServiceBase, Microsoft::Extensions::Hosting::IHostLifetime
public class WindowsServiceLifetime : System.ServiceProcess.ServiceBase, Microsoft.Extensions.Hosting.IHostLifetime
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public class WindowsServiceLifetime : System.ServiceProcess.ServiceBase, Microsoft.Extensions.Hosting.IHostLifetime
type WindowsServiceLifetime = class
    inherit ServiceBase
    interface IHostLifetime
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
type WindowsServiceLifetime = class
    inherit ServiceBase
    interface IHostLifetime
Public Class WindowsServiceLifetime
Inherits ServiceBase
Implements IHostLifetime
继承
属性
实现

构造函数

WindowsServiceLifetime(IHostEnvironment, IHostApplicationLifetime, ILoggerFactory, IOptions<HostOptions>)

初始化一个新 WindowsServiceLifetime 实例。

WindowsServiceLifetime(IHostEnvironment, IHostApplicationLifetime, ILoggerFactory, IOptions<HostOptions>, IOptions<WindowsServiceLifetimeOptions>)

侦听关闭信号并跟踪 Windows 服务的状态。

字段

MaxNameLength

指示服务名称的最大大小。

(继承自 ServiceBase)

属性

AutoLog

指示是否在事件日志中报告“开始”、“停止”、“暂停”以及“继续”命令。

(继承自 ServiceBase)
CanHandlePowerEvent

获取或设置一个值,该值指示服务是否可以处理计算机电源状态更改通知。

(继承自 ServiceBase)
CanHandleSessionChangeEvent

获取或设置一个值,该值指示服务是否可以处理从终端服务器会话接收到的会话更改事件。

(继承自 ServiceBase)
CanPauseAndContinue

获取或设置指示服务是否可以暂停并再继续的值。

(继承自 ServiceBase)
CanRaiseEvents

获取一个指示组件是否可以引发事件的值。

(继承自 Component)
CanShutdown

获取或设置一个值,该值指示系统关闭时是否应通知服务。

(继承自 ServiceBase)
CanStop

获取或设置一个值,该值指示服务启动后是否可以停止。

(继承自 ServiceBase)
Container

获取包含 IContainerComponent

(继承自 Component)
DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。

(继承自 Component)
EventLog

获取一个事件日志,它可用于将服务命令调用的通知(如“开始”和“停止”)写入“应用程序”事件日志。

(继承自 ServiceBase)
Events

获取附加到此 Component 的事件处理程序的列表。

(继承自 Component)
ExitCode

获取或设置服务的退出代码。

(继承自 ServiceBase)
ServiceHandle

获取服务的服务控制句柄。

(继承自 ServiceBase)
ServiceName

获取或设置用于向系统标识服务的简短名称。

(继承自 ServiceBase)
Site

获取或设置 ComponentISite

(继承自 Component)

方法

CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。

(继承自 MarshalByRefObject)
Dispose()

释放由 Component 使用的所有资源。

(继承自 Component)
Dispose(Boolean)

释放由 WindowsServiceLifetime 占用的资源。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetLifetimeService()
已过时.

检索控制此实例的生存期策略的当前生存期服务对象。

(继承自 MarshalByRefObject)
GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。

(继承自 Component)
GetType()

获取当前实例的 Type

(继承自 Object)
InitializeLifetimeService()
已过时.

获取生存期服务对象来控制此实例的生存期策略。

(继承自 MarshalByRefObject)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。

(继承自 MarshalByRefObject)
OnContinue()

在派生类中实现时,OnContinue() 于“服务控制管理器”(SCM) 将“继续”命令发送到服务时运行。 指定要在服务暂停后恢复正常功能时采取的操作。

(继承自 ServiceBase)
OnCustomCommand(Int32)

在派生类中实现时,OnCustomCommand(Int32) 于“服务控制管理器”(SCM) 向服务传递自定义命令时执行。 指定要在具有指定参数值的命令出现时采取的操作。

(继承自 ServiceBase)
OnPause()

在派生类中实现时,该方法于“服务控制管理器”(SCM) 将“暂停”命令发送到服务时执行。 指定要在服务暂停时采取的操作。

(继承自 ServiceBase)
OnPowerEvent(PowerBroadcastStatus)

当在派生类中实现时,该方法于计算机电源状态更改时执行。 这适用于膝上型计算机进入挂起模式时的情况,该模式不同于系统关闭。

(继承自 ServiceBase)
OnSessionChange(SessionChangeDescription)

从终端服务器会话接收到更改事件时执行。

(继承自 ServiceBase)
OnShutdown()

侦听关闭信号并跟踪 Windows 服务的状态。

OnShutdown()

在派生类中实现时,该方法于系统即将关闭时执行。 该方法指定应在系统即将关闭前执行的处理。

(继承自 ServiceBase)
OnStart(String[])

当在派生类中实现时,在下列情况下执行:在“服务控制管理器”(SCM) 向服务发送“开始”命令时,或者在操作系统启动时(对于自动启动的服务)。 指定服务启动时采取的操作。

OnStop()

当服务控制管理器 (SCM) 向服务发送 Stop 命令时执行。 ApplicationStopping触发并等待 ApplicationStopped。 此方法返回后不久,服务将在 SCM 中标记为已停止,并且进程可能随时退出。

RequestAdditionalTime(Int32)

为挂起操作请求额外的时间。

(继承自 ServiceBase)
RequestAdditionalTime(TimeSpan)

从 OnStart、OnStop、OnPause 或 OnContinue 调用此方法时,指定的等待提示将传递给服务控制管理器,以避免将服务标记为未响应。

(继承自 ServiceBase)
ServiceMainCallback(Int32, IntPtr)

注册命令处理程序并启动服务。

(继承自 ServiceBase)
Stop()

停止执行服务。

(继承自 ServiceBase)
StopAsync(CancellationToken)

异步停止和关闭主机。 通过 StopAsync(CancellationToken) 调用此方法。

ToString()

返回包含 Component 的名称的 String(如果有)。 不应重写此方法。

(继承自 Component)
WaitForStartAsync(CancellationToken)

异步等待,直到启动完成,然后再继续。 在 StartAsync(CancellationToken) 开头调用此方法。 它可用于延迟启动,直到外部事件发出信号。

事件

Disposed

在通过调用 Dispose() 方法释放组件时发生。

(继承自 Component)

适用于