ServiceController.CanStop Tulajdonság

Definíció

Beolvas egy értéket, amely jelzi, hogy a szolgáltatás leállítható-e az elindítása után.

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

Tulajdonság értéke

trueha a szolgáltatás leállítható, és a OnStop() metódus meghívható; ellenkező esetben. false

Attribútumok

Kivételek

Hiba történt egy rendszer API elérésekor.

A szolgáltatás nem található.

Példák

Az alábbi példa bemutatja a tulajdonság használatát annak CanStop meghatározására, hogy egy szolgáltatás biztosít-e kezelőt egy stop eseményhez. Ez a példa egy nagyobb, az ServiceController osztályhoz tartozó példa része.

// 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())

A következőre érvényes: