ServiceController.Stop 메서드

정의

오버로드

Stop()

이 서비스와 이 서비스에 종속되는 서비스를 중지합니다.

Stop(Boolean)

서비스를 중지하고 필요에 따라 이 서비스에 종속된 모든 서비스를 중지합니다.

Stop()

이 서비스와 이 서비스에 종속되는 서비스를 중지합니다.

public:
 void Stop();
public void Stop ();
member this.Stop : unit -> unit
Public Sub Stop ()

예외

시스템 API에 액세스할 때 오류가 발생했습니다.

서비스를 찾을 수 없습니다.

예제

다음 예제에서는 클래스를 ServiceController 사용하여 텔넷 서비스의 현재 상태를 확인합니다. 서비스가 중지되면 예제에서 서비스를 시작합니다. 서비스가 실행 중이면 서비스를 중지하는 예제입니다.

// Toggle the Telnet service - 
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController^ sc = gcnew ServiceController(  "Telnet" );
if ( sc )
{
   Console::WriteLine(  "The Telnet service status is currently set to {0}", sc->Status );
   if ( (sc->Status == (ServiceControllerStatus::Stopped) ) || (sc->Status == (ServiceControllerStatus::StopPending) ) )
   {
      // Start the service if the current status is stopped.
      Console::WriteLine(  "Starting the Telnet service..." );
      sc->Start();
   }
   else
   {
      // Stop the service if its status is not set to "Stopped".
      Console::WriteLine(  "Stopping the Telnet service..." );
      sc->Stop();
   }

   // Refresh and display the current service status.
   sc->Refresh();
   Console::WriteLine(  "The Telnet service status is now set to {0}.", sc->Status );

// Toggle the Telnet service -
// If it is started (running, paused, etc), stop the service.
// If it is stopped, start the service.
ServiceController sc = new ServiceController("Telnet");
Console.WriteLine("The Telnet service status is currently set to {0}",
                  sc.Status.ToString());

if  ((sc.Status.Equals(ServiceControllerStatus.Stopped)) ||
     (sc.Status.Equals(ServiceControllerStatus.StopPending)))
{
   // Start the service if the current status is stopped.

   Console.WriteLine("Starting the Telnet service...");
   sc.Start();
}
else
{
   // Stop the service if its status is not set to "Stopped".

   Console.WriteLine("Stopping the Telnet service...");
   sc.Stop();
}

// Refresh and display the current service status.
sc.Refresh();
Console.WriteLine("The Telnet service status is now set to {0}.",
                   sc.Status.ToString());

' Toggle the Telnet service - 
' If it is started (running, paused, etc), stop the service.
' If it is stopped, start the service.
Dim sc As New ServiceController("Telnet")
Console.WriteLine("The Telnet service status is currently set to {0}", sc.Status)

If sc.Status.Equals(ServiceControllerStatus.Stopped) Or sc.Status.Equals(ServiceControllerStatus.StopPending) Then
   ' Start the service if the current status is stopped.
   Console.WriteLine("Starting the Telnet service...")
   sc.Start()
Else
   ' Stop the service if its status is not set to "Stopped".
   Console.WriteLine("Stopping the Telnet service...")
   sc.Stop()
End If

' Refresh and display the current service status.
sc.Refresh()
Console.WriteLine("The Telnet service status is now set to {0}.", sc.Status)

설명

모든 서비스가 해당 작업에 대해 이 서비스에 의존하는 경우 이 서비스가 중지되기 전에 중지됩니다. 이 DependentServices 속성에는 이 서비스에 의존하는 서비스 집합이 포함되어 있습니다.

이 서비스가 의존하는 서비스를 중지하는 경우 부모 서비스의 메서드 내에서 이 서비스의 메서드를 Stop 호출 Stop 합니다. 이 속성에는 ServicesDependedOn 이 서비스가 의존하는 서비스가 포함됩니다.

추가 정보

적용 대상

Stop(Boolean)

서비스를 중지하고 필요에 따라 이 서비스에 종속된 모든 서비스를 중지합니다.

public:
 void Stop(bool stopDependentServices);
public void Stop (bool stopDependentServices);
member this.Stop : bool -> unit
Public Sub Stop (stopDependentServices As Boolean)

매개 변수

stopDependentServices
Boolean

true 서비스와 함께 실행 중인 모든 종속 서비스를 중지하려면 false 서비스만 중지합니다.

설명

다른 서비스가 이 서비스에 의존하는 경우 이 메서드를 호출하기 전에 수동으로 전달 true stopDependentServices 하거나 중지해야 합니다.

적용 대상