当前位置: 首页>>代码示例>>C#>>正文


C# ServiceController.Refresh方法代码示例

本文整理汇总了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;
        }
    }
开发者ID:danygolden,项目名称:gianfratti,代码行数:37,代码来源:frmMain.cs

示例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;
    }
开发者ID:haikavn,项目名称:x.stat,代码行数:32,代码来源:ServiceManager.cs


注:本文中的ServiceController.Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。