本文整理汇总了C#中ServiceController.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceController.Refresh方法的具体用法?C# ServiceController.Refresh怎么用?C# ServiceController.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceController
的用法示例。
在下文中一共展示了ServiceController.Refresh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateServiceStatus
private void UpdateServiceStatus()
{
// Check each service
try
{
fUpdatingUI = true;
this.sbInfo.Text = "Verificando Status do Serviço . . ";
this.sbInfo.Refresh();
// We could walk through the collection of services
// two ways. One would be to enumerate all the services
// via mcolSvc and then find the particular item in the
// list view control to update its status.
// The second method is to do the following code which
// seems a bit easier since the collection is keyed by
// the service display name which we get from the list view
// control.
foreach(ListViewItem lvi in this.lvServices.Items)
{
msvc = ((ServiceController) (mcolSvcs[lvi.Text]));
msvc.Refresh();
lvi.SubItems[1].Text = msvc.Status.ToString();
//Next lvi;
}
UpdateUIForSelectedService();
}
catch (Exception exp)
{
MessageBox.Show(exp.Message, exp.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
this.sbInfo.Text = "Lendo";
fUpdatingUI = false;
}
}
示例2: ContinueService
/// <summary>
/// Continues the service.
/// </summary>
/// <param name="serviceName">Name of the service.</param>
/// <returns></returns>
public static bool ContinueService(string serviceName)
{
using (ServiceController sc = new ServiceController(serviceName))
{
if (sc.CanPauseAndContinue)
{
sc.Continue();
while (sc.Status != ServiceControllerStatus.ContinuePending)
{
Thread.Sleep(1000);
sc.Refresh();
}
if (sc.Status == ServiceControllerStatus.Running)
{
return true;
}
else
{
return false;
}
}
}
return false;
}