ServiceController.CanShutdown Egenskap

Definition

Hämtar ett värde som anger om tjänsten ska meddelas när systemet stängs av.

public:
 property bool CanShutdown { bool get(); };
public bool CanShutdown { get; }
[System.ServiceProcess.ServiceProcessDescription("SPCanShutdown")]
public bool CanShutdown { get; }
member this.CanShutdown : bool
[<System.ServiceProcess.ServiceProcessDescription("SPCanShutdown")>]
member this.CanShutdown : bool
Public ReadOnly Property CanShutdown As Boolean

Egenskapsvärde

trueom tjänsten ska meddelas när systemet stängs av. annars . false

Attribut

Undantag

Ett fel uppstod vid åtkomst till ett system-API.

Det gick inte att hitta tjänsten.

Exempel

I följande exempel visas hur egenskapen används CanShutdown för att avgöra om en tjänst tillhandahåller en hanterare för en avstängningshändelse. Det här exemplet är en del av ett större exempel som tillhandahålls ServiceController för klassen.

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

Gäller för