ServiceController.CanStop Propriété

Définition

Obtient une valeur indiquant si le service peut être arrêté après avoir démarré.

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

Valeur de propriété

Boolean

true si le service peut être arrêté et la méthode OnStop() appelée ; sinon, false.

Attributs

Exceptions

Une erreur s'est produite lors de l'accès à une API système.

Le service est introuvable.

Exemples

L’exemple suivant illustre l’utilisation de la CanStop propriété pour déterminer si un service fournit un gestionnaire pour un événement d’arrêt. Cet exemple fait partie d’un exemple plus grand fourni pour la ServiceController classe.

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

S’applique à