<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      代碼改變世界

      ServicesController 的使用

      2014-05-26 15:53  極無憲  閱讀(345)  評論(0)    收藏  舉報(bào)
      using System;
      using System.ServiceProcess;
      using System.Diagnostics;
      using System.Threading;
      
      namespace ServiceControllerSample
      {
          class Program
          {
              public enum SimpleServiceCustomCommands
              { StopWorker = 128, RestartWorker, CheckWorker };
              static void Main(string[] args)
              {
                  ServiceController[] scServices;
                  scServices = ServiceController.GetServices();
      
                  foreach (ServiceController scTemp in scServices)
                  {
      
                      if (scTemp.ServiceName == "Simple Service")
                      {
                          // Display properties for the Simple Service sample
                          // from the ServiceBase example.
                          ServiceController sc = new ServiceController("Simple Service");
                          Console.WriteLine("Status = " + sc.Status);
                          Console.WriteLine("Can Pause and Continue = " + sc.CanPauseAndContinue);
                          Console.WriteLine("Can ShutDown = " + sc.CanShutdown);
                          Console.WriteLine("Can Stop = " + sc.CanStop);
                          if (sc.Status == ServiceControllerStatus.Stopped)
                          {
                              sc.Start();
                              while (sc.Status == ServiceControllerStatus.Stopped)
                              {
                                  Thread.Sleep(1000);
                                  sc.Refresh();
                              }
                          }
                          // Issue custom commands to the service
                          // enum SimpleServiceCustomCommands 
                          //    { StopWorker = 128, RestartWorker, CheckWorker };
                          sc.ExecuteCommand((int)SimpleServiceCustomCommands.StopWorker);
                          sc.ExecuteCommand((int)SimpleServiceCustomCommands.RestartWorker);
                          sc.Pause();
                          while (sc.Status != ServiceControllerStatus.Paused)
                          {
                              Thread.Sleep(1000);
                              sc.Refresh();
                          }
                          Console.WriteLine("Status = " + sc.Status);
                          sc.Continue();
                          while (sc.Status == ServiceControllerStatus.Paused)
                          {
                              Thread.Sleep(1000);
                              sc.Refresh();
                          }
                          Console.WriteLine("Status = " + sc.Status);
                          sc.Stop();
                          while (sc.Status != ServiceControllerStatus.Stopped)
                          {
                              Thread.Sleep(1000);
                              sc.Refresh();
                          }
                          Console.WriteLine("Status = " + sc.Status);
                          String[] argArray = new string[] { "ServiceController arg1", "ServiceController arg2" };
                          sc.Start(argArray);
                          while (sc.Status == ServiceControllerStatus.Stopped)
                          {
                              Thread.Sleep(1000);
                              sc.Refresh();
                          }
                          Console.WriteLine("Status = " + sc.Status);
                          // Display the event log entries for the custom commands
                          // and the start arguments.
                          EventLog el = new EventLog("Application");
                          EventLogEntryCollection elec = el.Entries;
                          foreach (EventLogEntry ele in elec)
                          {
                              if (ele.Source.IndexOf("SimpleService.OnCustomCommand") >= 0 |
                                  ele.Source.IndexOf("SimpleService.Arguments") >= 0)
                                  Console.WriteLine(ele.Message);
                          }
                      }
                  }
      
      
              }
          }
      }
      // This sample displays the following output if the Simple Service
      // sample is running:
      //Status = Running
      //Can Pause and Continue = True
      //Can ShutDown = True
      //Can Stop = True
      //Status = Paused
      //Status = Running
      //Status = Stopped
      //Status = Running
      //4:14:49 PM - Custom command received: 128
      //4:14:49 PM - Custom command received: 129
      //ServiceController arg1
      //ServiceController arg2
      

      以上代碼轉(zhuǎn)自msdn:http://msdn.microsoft.com/zh-cn/library/system.serviceprocess.servicecontroller(v=vs.110).aspx

      今天自己調(diào)試了一個(gè)ServicesController ,本來一個(gè)停止服務(wù)由于沒有刷新,始終在一個(gè)狀態(tài)下

       while (sc.Status != ServiceControllerStatus.Stopped)
                          {
                              Thread.Sleep(1000);
                              
                          }
      

        如果是怎么寫的話,狀態(tài)會一直在Stoppending

      需要加入一句sc.Refresh();

       while (sc.Status != ServiceControllerStatus.Stopped)
                          {
                              Thread.Sleep(1000);
                              sc.Refresh();
                          }

       

      
      
      主站蜘蛛池模板: 国产成人欧美综合在线影院| 欧美激情 亚洲 在线| 在线播放亚洲成人av| 精品无套挺进少妇内谢| 国产精品午夜福利精品| 无码人妻精品一区二区三区蜜桃| 国产成人一区二区三区视频免费 | 无套中出极品少妇白浆| 免费看视频的网站| 夜夜躁狠狠躁日日躁| 国产人成777在线视频直播| 精品免费看国产一区二区| 57pao成人国产永久免费视频| 中文 在线 日韩 亚洲 欧美| 日本成本人片免费网站| 国产一区二区丰满熟女人妻| 国产午夜精品福利91| 色琪琪丁香婷婷综合久久| 亚洲欧洲久久激情久av| 亚洲色拍拍噜噜噜最新网站| 久久成人 久久鬼色| 亚洲一区av在线观看| 国产国拍亚洲精品永久软件| 南投县| 成人网站av亚洲国产| 精品999日本久久久影院| 最近中文字幕日韩有码| 国产成人亚洲精品狼色在线| 综合偷自拍亚洲乱中文字幕| 亚洲 制服 丝袜 无码| 一本久道中文无码字幕av| 精品国产国语对白主播野战 | 日本无人区一区二区三区| 国产欧美亚洲精品a| 日韩视频中文字幕精品偷拍| 日韩精品亚洲精品第一页| 精品国产污污免费网站| 99精品久久毛片a片| 亚洲人成网线在线播放VA| 汉源县| 四虎永久地址www成人|