ServiceController.Refresh Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Refreshes property values by resetting the properties to their current values.

Namespace:   System.ServiceProcess
Assembly:  System.ServiceProcess (in System.ServiceProcess.dll)

public void Refresh()

The Refresh method causes the ServicesDependedOn, DependentServices, and Status properties to be reset to their current values when they are next referenced.

The following example demonstrates the use of the Refresh method to obtain the status of a service. The code instructs a service to pause, and then waits for the status to reflect the change. This example is part of a larger example that is provided for the ServiceController class.

sc.Pause();
while (sc.Status != ServiceControllerStatus.Paused)
{
    Thread.Sleep(1000);
    sc.Refresh();
}
Console.WriteLine("Status = " + sc.Status);

.NET Framework
Available since 1.1
Return to top
Show: