Example #1
0
 public static void Main(string[] args)
 {
     Comm2IPService service = new Comm2IPService();
     if (!Environment.UserInteractive)
     {
         ServiceBase.Run(service);
     }
     else
     {
         try
         {
             if (args.Length == 1)
             {
                 if (args[0] == "--install") ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
                 else if (args[0] == "--uninstall") ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
             }
             else
             {
                 ServiceMapping sm = service.ParseParameters(args);
                 if (service.CheckParameters(sm))
                 {
                     Console.WriteLine("Running in interactive mode, press Ctrl-C to abort...");
                     Comm2IP.Comm2IP com = new Comm2IP.Comm2IP(sm.ipAddress, sm.ipPort, sm.commPort, sm.commRate);
                     Thread listener = new Thread(new ThreadStart(com.Run));
                     listener.Start();
                     listener.Join();
                 }
             }
         }
         catch (Exception e)
         {
             log.Fatal(e);
         }
     }
 }
Example #2
0
        public static void Main(string[] args)
        {
            Comm2IPService service = new Comm2IPService();

            if (!Environment.UserInteractive)
            {
                ServiceBase.Run(service);
            }
            else
            {
                try
                {
                    if (args.Length == 1)
                    {
                        if (args[0] == "--install")
                        {
                            ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
                        }
                        else if (args[0] == "--uninstall")
                        {
                            ManagedInstallerClass.InstallHelper(new string[] { "/u", Assembly.GetExecutingAssembly().Location });
                        }
                    }
                    else
                    {
                        ServiceMapping sm = service.ParseParameters(args);
                        if (service.CheckParameters(sm))
                        {
                            Console.WriteLine("Running in interactive mode, press Ctrl-C to abort...");
                            Comm2IP.Comm2IP com      = new Comm2IP.Comm2IP(sm.ipAddress, sm.ipPort, sm.commPort, sm.commRate);
                            Thread          listener = new Thread(new ThreadStart(com.Run));
                            listener.Start();
                            listener.Join();
                        }
                    }
                }
                catch (Exception e)
                {
                    log.Fatal(e);
                }
            }
        }