CSHARP 2
Untitled Guest on 22nd February 2025 02:36:27 PM
  1. using System;
  2. using System.ServiceProcess;
  3.  
  4. static class Program
  5. {
  6.     static void Main()
  7.     {
  8.         if (Environment.UserInteractive)
  9.         {
  10.             // Running as a console app
  11.             MyService service = new MyService();
  12.             service.OnStart(null);
  13.             Console.WriteLine("Press any key to stop the service...");
  14.             Console.ReadKey();
  15.             service.OnStop();
  16.         }
  17.         else
  18.         {
  19.             // Running as a Windows service
  20.             ServiceBase[] ServicesToRun;
  21.             ServicesToRun = new ServiceBase[]
  22.             {
  23.                 new MyService()
  24.             };
  25.             ServiceBase.Run(ServicesToRun);
  26.         }
  27.     }
  28. }

Hightechrobo bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.