Csharp/C Sharp/Development Class/Service

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

demonstrates service control

<source lang="csharp"> /* Mastering Visual C# .NET by Jason Price, Mike Gunderloy Publisher: Sybex; ISBN: 0782129110

  • /

/*

 Example21_15.cs demonstrates service control
  • /

using System; using System.ServiceProcess; public class Example21_15 {

 public static void Main() 
 {
   // connect to the Alerter service
   ServiceController scAlerter = new ServiceController("Alerter");
   Console.WriteLine(scAlerter.DisplayName);
   Console.WriteLine(scAlerter.CanStop);
   scAlerter.Stop();
   Console.WriteLine("Service stopped");
   scAlerter.Start();
   Console.WriteLine("Service started");
 }

}


      </source>