Partager via


ServiceController.CanStop Propriété

Définition

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

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é

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

Attributs

Exceptions

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

Le service n’a pas été trouvé.

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 large 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 à