發表文章

目前顯示的是 1月, 2014的文章

監控服務(Service)的目前狀態

一般撰寫完Service程式之後,Service都是在背景持續的作業,前景部分是不會看到任何的介面的,那麼就會有一些延伸的需求產生。例如說如何知道目前Service的狀態,或是怎麼從Service中取出一些目前運作的訊息等等;這邊就先來看看要怎麼去取得Service的狀態。 要取得目前服務的狀態其實在實作上非常的簡單,只要利用ServiceController的功能就可以達到了,例如下面這個範例可以列出目前系統中的所有服務以及該服務是否支援『停止』的動作 using  System; using  System . ServiceProcess; using  System . Windows . Forms; namespace  svcMonitor {      public   partial   class   Form1  :  Form     {          ServiceController [] svcList;          public  Form1()         {             InitializeComponent();         }          private   void  btnRefresh_Click( object  sender,  EventArgs  e)         {             svcList  =   ServiceController . GetServices();              foreach  ( var  item  in  svcList)             {                 txtMessage . Text  +=                    item . ServiceName  +   " : "   +  item . Status . ToString()  +   Environment . NewLine;                 txtMessage . Text  +=                     "    "   +  item . ServiceName  +   " : &qu

Visual Studio 2013 update 1

Visual Studio 2013 Update 1 正式版本已經推出了,有使用的朋友們可以參考下面連結進行更新 Reference http://blogs.msdn.com/b/bharry/archive/2014/01/20/vs-2013-1-update-1-is-available.aspx Download link http://www.microsoft.com/zh-tw/download/details.aspx?id=41650 Happy coding !