←Select platform

Status Property

Summary

Indicates the status of the Window Service.

Syntax

C#
C++/CLI
public ServiceControllerStatus Status { get; } 
public:  
   property ServiceControllerStatus^ Status 
   { 
      ServiceControllerStatus^ get() 
   } 

Property Value

The status of the Window Service.

Remarks

The status of a Windows Service can be one of the following:

For more information, see ServiceControllerStatus.

Example

C#
using Leadtools.Dicom.AddIn; 
using Leadtools.Dicom.AddIn.Common; 
using Leadtools.Dicom.Server.Admin; 
 
 
public static class ExtendedServiceControllerExample 
{ 
   static AutoResetEvent statusChangedEvent = new AutoResetEvent(false); 
   static ServiceControllerStatus desiredStatus = ServiceControllerStatus.Stopped; 
 
   public static void StartService(ExtendedServiceController controller) 
   { 
      if (controller.Status != System.ServiceProcess.ServiceControllerStatus.Running) 
      { 
         desiredStatus = ServiceControllerStatus.Running; 
         statusChangedEvent.Reset(); 
         controller.Start(); 
         statusChangedEvent.WaitOne(); 
      } 
   } 
   public static void StopService(ExtendedServiceController controller) 
   { 
      if (controller.Status != System.ServiceProcess.ServiceControllerStatus.Stopped) 
      { 
         desiredStatus = ServiceControllerStatus.Stopped; 
         statusChangedEvent.Reset(); 
         controller.Stop(); 
         statusChangedEvent.WaitOne(); 
      } 
   } 
 
   public static void ExtendedServiceControllerSample() 
   { 
      ExtendedServiceController controller = new ExtendedServiceController("L22_PACS_SCP64"); 
      controller.StatusChanged += Controller_StatusChanged; 
 
      StartService(controller); 
      StopService(controller); 
      StartService(controller); 
      StopService(controller); 
   } 
 
   private static void Controller_StatusChanged(object sender, ServiceStatusEventArgs e) 
   { 
      ExtendedServiceController controller = sender as ExtendedServiceController; 
      if (controller != null) 
      { 
         try 
         { 
            Console.WriteLine($"Status Changed: {e.Status}"); 
         } 
         finally 
         { 
            if (controller.Status == desiredStatus) 
            { 
               statusChangedEvent.Set(); 
            } 
         } 
      } 
   } 
} 

Requirements

Target Platforms

See Also

ServiceStatusEventArgs Class

ServiceStatusEventArgs Members

Leadtools.Dicom.Server.Admin Namespace

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom.Server.Admin Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.