예제 #1
0
        protected override void OnStart(String[] args)
        {
            program = new TelnetPerfmonServer();
            ThreadStart ts = new ThreadStart(() => program.Run(args));

            m_thread = new Thread(ts);
            m_thread.Start();
            base.OnStart(args);
        }
예제 #2
0
 static void Main(String[] args)
 {
     if (args != null && args.Length == 1 && args[0].Length > 1
        && (args[0][0] == '-' || args[0][0] == '/'))
     {
         switch (args[0].Substring(1).ToLower())
         {
             default:
                 Console.WriteLine("Huh?!");
                 break;
             case "uninstall":
             case "u":
                 {
                     ServiceController[] scServices = ServiceController.GetServices();
                     foreach (ServiceController sc in scServices)
                         if (sc.ServiceName == name)
                             if (sc.Status != ServiceControllerStatus.Stopped && sc.Status != ServiceControllerStatus.StopPending)
                                 sc.Stop();
                     ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
                     break;
                 }
             case "console":
             case "c":
                 {
                     TelnetPerfmonServer program = new TelnetPerfmonServer();
                     program.Run(args.Skip(1).ToArray());
                     break;
                 }
          /*   case "p":
                 {
                     TelnetPerfmonServer program = new TelnetPerfmonServer();
                     Thread t =new Thread(() => program.Run(new String[]{}));
                     t.Start();
                     Thread.Sleep(5000);
                     program.Stop();
                     break;
                 }*/
         }
     }
     else
     {
         bool found = false;
         foreach (ServiceController sc in ServiceController.GetServices())
             if (sc.ServiceName == name)
                 found = true;
         if (!found)
             install();
         else
             ServiceBase.Run(new ServiceBase[] { new TelnetPerfmonService() });
     }
 }