Example #1
0
        static void Main(string[] args)
        {
            ProgramCommandLineArguments pargs = new ProgramCommandLineArguments();

            if (!Parser.ParseArguments(args, pargs))
            {
                AllocConsole();
                Parser.ParseArgumentsWithUsage(args, pargs);
                Console.WriteLine("Press any key to continue ...");
                Console.ReadKey();
                FreeConsole();
                return;
            }

            if (pargs.debug)
            {
                try
                {
                    AllocConsole();

                    AssemblyName name = Assembly.GetExecutingAssembly().GetName();
                    Console.WriteLine("{0}: {1}", name.Name, name.Version);
                    ServiceEngine serviceEngine = new ServiceEngine();

                    Console.CancelKeyPress += delegate
                    {
                        Console.WriteLine("Stopping service, please wait ...");
                        serviceEngine.StopOnConsole();
                    };

                    serviceEngine.RunOnConsole(pargs.services);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Press any key to continue ...");
                    Console.ReadKey();
                }
                finally
                {
                    FreeConsole();
                }
            }
            else
            {
                ServiceEngine serviceEngine = new ServiceEngine();
                serviceEngine.RunAsService(pargs.services);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            ProgramCommandLineArguments pargs = new ProgramCommandLineArguments();
            if (!Parser.ParseArguments(args, pargs))
            {
                AllocConsole();
                Parser.ParseArgumentsWithUsage(args, pargs);
                Console.WriteLine("Press any key to continue ...");
                Console.ReadKey();
                FreeConsole();
                return;
            }

            if (pargs.debug)
            {
                try
                {
                    AllocConsole();

                    AssemblyName name = Assembly.GetExecutingAssembly().GetName();
                    Console.WriteLine("{0}: {1}", name.Name, name.Version);
                    ServiceEngine serviceEngine = new ServiceEngine();

                    Console.CancelKeyPress += delegate
                    {
                        Console.WriteLine("Stopping service, please wait ...");
                        serviceEngine.StopOnConsole();
                    };

                    serviceEngine.RunOnConsole(pargs.services);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Press any key to continue ...");
                    Console.ReadKey();
                }
                finally
                {
                    FreeConsole();
                }
            }
            else
            {
                ServiceEngine serviceEngine = new ServiceEngine();
                serviceEngine.RunAsService(pargs.services);
            }
        }