ServiceController.CanStop Property
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.
Gets a value indicating whether the service can be stopped after it has started.
public:
property bool CanStop { bool get(); };
public bool CanStop { get; }
[System.ServiceProcess.ServiceProcessDescription("SPCanStop")]
public bool CanStop { get; }
member this.CanStop : bool
[<System.ServiceProcess.ServiceProcessDescription("SPCanStop")>]
member this.CanStop : bool
Public ReadOnly Property CanStop As Boolean
true
if the service can be stopped and the OnStop() method called; otherwise, false
.
- Attributes
An error occurred when accessing a system API.
The service was not found.
The following example demonstrates the use of the CanStop property to determine whether a service provides a handler for a stop event. This example is part of a larger example that is provided for the ServiceController class.
// Display properties for the Simple Service sample
// from the ServiceBase example.
ServiceController sc = new ServiceController("Simple Service");
Console.WriteLine("Status = " + sc.Status);
Console.WriteLine("Can Pause and Continue = " + sc.CanPauseAndContinue);
Console.WriteLine("Can ShutDown = " + sc.CanShutdown);
Console.WriteLine("Can Stop = " + sc.CanStop);
' Display properties for the Simple Service sample
' from the ServiceBase example
Dim sc As New ServiceController("Simple Service")
Console.WriteLine("Status = " + sc.Status.ToString())
Console.WriteLine("Can Pause and Continue = " + _
sc.CanPauseAndContinue.ToString())
Console.WriteLine("Can ShutDown = " + sc.CanShutdown.ToString())
Console.WriteLine("Can Stop = " + sc.CanStop.ToString())
מוצר | גירסאות |
---|---|
.NET | Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
משוב של .NET
.NET הוא פרויקט קוד פתוח. בחר קישור כדי לספק משוב: