Editar

Compartir a través de


ServiceController.Refresh Method

Definition

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

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

Examples

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);
sc.Pause()
While sc.Status <> ServiceControllerStatus.Paused
    Thread.Sleep(1000)
    sc.Refresh()
End While
Console.WriteLine("Status = " + sc.Status.ToString())

Remarks

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

Applies to