ServiceBase.OnStop Method
Definition
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.
When implemented in a derived class, executes when a Stop command is sent to the service by the Service Control Manager (SCM). Specifies actions to take when a service stops running.
protected:
virtual void OnStop();
protected virtual void OnStop ();
abstract member OnStop : unit -> unit
override this.OnStop : unit -> unit
Protected Overridable Sub OnStop ()
Remarks
Use OnStop to specify the processing that occurs when the service receives a Stop command.
When the SCM receives a Stop command, it uses the value of CanStop to verify whether the service accepts Stop commands. If CanStop is true
, the Stop command is passed to the service, and the OnStop method is called if it is defined. If OnStop is not implemented in the service, the SCM handles the Stop command.
If CanStop is false
, the SCM ignores the Stop command. It is not passed to the service. The Stop command returns and throws an exception.
OnStop is expected to be overridden in the derived class. For the service to be useful, OnStart and OnStop should both be implemented in your service class.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기