Пример #1
0
 /// <summary>
 /// Program entry point
 /// </summary>
 /// <param name="args">
 /// Program arguments
 /// </param>
 static void Main(String[] args)
 {
     if (!Environment.UserInteractive)
     ServiceBase.Run(new WindowsService());
      else
      {
     using (ServiceHost host = new ServiceHost())
     {
        if (host.Startup())
        {
           Console.Write("Press enter to shut down.");
           Console.ReadLine();
        }
     }
      }
 }
Пример #2
0
 /// <summary>
 /// Service stop override
 /// </summary>
 protected override void OnStop()
 {
     if (this.host != null)
     this.host.Dispose();
      this.host = null;
 }
Пример #3
0
 /// <summary>
 /// Service startup override
 /// </summary>
 /// <param name="args">
 /// Service command line parameters
 /// </param>
 protected override void OnStart(String[] args)
 {
     this.host = new ServiceHost();
      if (!this.host.Startup())
     this.Stop();
 }