Esempio n. 1
0
        static void Main(string[] args)
        {
            // Print welcome information :-)
            Console.WriteLine("********************************************************");
            Console.WriteLine("*                                                      *");
            Console.WriteLine("*   AlarmWorkflow Service Console                      *");
            Console.WriteLine("*                             FOR DEBUGGING ONLY!      *");
            Console.WriteLine("*                                                      *");
            Console.WriteLine("*        !!! Press ESCAPE to quit safely !!!           *");
            Console.WriteLine("*                                                      *");
            Console.WriteLine("********************************************************");
            Console.WriteLine();
            Console.WriteLine("Starting service...");

            // Catch all unhandled exceptions and display them.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // Initialize the service
            using (var service = new AlarmWorkflow.Windows.Service.AlarmWorkflowServiceManager())
            {
                // Register listeners
                Logger.Instance.RegisterListener(new RelayLoggingListener(LoggingListener));
                Logger.Instance.RegisterListener(new DiagnosticsLoggingListener());

                // Start the service
                service.OnStart();

                // Wait for user exit
                while (true)
                {
                    if (Console.KeyAvailable)
                    {
                        if (Console.ReadKey().Key == ConsoleKey.Escape)
                        {
                            break;
                        }
                    }

                    Thread.Sleep(1);
                }

                // Stop service
                service.OnStop();
            }

            Console.WriteLine("Shutting down complete. Press any key to exit.");
            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // Print welcome information :-)
            Console.WriteLine("********************************************************");
            Console.WriteLine("*                                                      *");
            Console.WriteLine("*   AlarmWorkflow Service Console                      *");
            Console.WriteLine("*                             FOR DEBUGGING ONLY!      *");
            Console.WriteLine("*                                                      *");
            Console.WriteLine("*        !!! Press ESCAPE to quit safely !!!           *");
            Console.WriteLine("*                                                      *");
            Console.WriteLine("********************************************************");
            Console.WriteLine();
            Console.WriteLine("Starting service...");

            // Catch all unhandled exceptions and display them.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            // Initialize the service
            using (var service = new AlarmWorkflow.Windows.Service.AlarmWorkflowServiceManager())
            {
                // Register listeners
                Logger.Instance.RegisterListener(new RelayLoggingListener(LoggingListener));
                Logger.Instance.RegisterListener(new DiagnosticsLoggingListener());

                // Start the service
                service.OnStart();

                // Wait for user exit
                while (true)
                {
                    if (Console.KeyAvailable)
                    {
                        if (Console.ReadKey().Key == ConsoleKey.Escape)
                        {
                            break;
                        }
                    }

                    Thread.Sleep(1);
                }

                // Stop service
                service.OnStop();
            }

            Console.WriteLine("Shutting down complete. Press any key to exit.");
            Console.ReadKey();
        }