예제 #1
0
        private static void Main(string[] args)
        {
            Log.Info("Starting Up");

            var singleGlobalInstance = Attempt.Get(() => new SingleGlobalInstance()).Value;
            if (singleGlobalInstance == null)
            {
                if (!Environment.UserInteractive) return;
                Console.WriteLine("Another instance of the application is running. Press any key to exit.");
                Console.ReadKey();
                return;
            }

            using (singleGlobalInstance)
            {
                var svc = new BitviseService();

                if (Environment.UserInteractive)
                {
                    svc.Start(args);
                    Console.WriteLine("Press Enter to stop the service...");
                    Console.ReadLine();
                    svc.Stop();
                    Console.WriteLine("The service is stopped. Press Enter to terminate...");
                    Console.ReadLine();
                }
                else
                {
                    ServiceBase.Run(svc);
                }

                // wait for any straggling async log entries
                LogManager.Global.Dispose();
            }
        }
예제 #2
0
        private static void Main(string[] args)
        {
            Log.Info("Starting Up");

            var singleGlobalInstance = Attempt.Get(() => new SingleGlobalInstance()).Value;

            if (singleGlobalInstance == null)
            {
                if (!Environment.UserInteractive)
                {
                    return;
                }
                Console.WriteLine("Another instance of the application is running. Press any key to exit.");
                Console.ReadKey();
                return;
            }

            using (singleGlobalInstance)
            {
                var svc = new BitviseService();

                if (Environment.UserInteractive)
                {
                    svc.Start(args);
                    Console.WriteLine("Press Enter to stop the service...");
                    Console.ReadLine();
                    svc.Stop();
                    Console.WriteLine("The service is stopped. Press Enter to terminate...");
                    Console.ReadLine();
                }
                else
                {
                    ServiceBase.Run(svc);
                }

                // wait for any straggling async log entries
                LogManager.Global.Dispose();
            }
        }