Exemplo n.º 1
0
        private static void RunService(Action <ISchedulingService> setupHandler, bool debug)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException +=
                    (o, e) => ExceptionHelper.LogUnhandledException(e.ExceptionObject);

                using (var service = new SchedulingService())
                {
                    setupHandler(service);

                    if (debug)
                    {
                        service.Start();
                        Console.ReadLine();
                        service.Stop();
                    }
                    else
                    {
                        using (var adapter = new ServiceProcessAdapter(service))
                        {
                            ServiceBase.Run(adapter);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionHelper.LogUnhandledException(exception);
            }
        }
Exemplo n.º 2
0
 protected override void OnStart(string[] args)
 {
     _service.Start();
 }
Exemplo n.º 3
0
        private static void RunService(Action<ISchedulingService> setupHandler, bool debug)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException +=
                    (o, e) => ExceptionHelper.LogUnhandledException(e.ExceptionObject);

                using (var service = new SchedulingService())
                {
                    setupHandler(service);

                    if (debug)
                    {
                        service.Start();
                        Console.ReadLine();
                        service.Stop();
                    }
                    else
                    {
                        using (var adapter = new ServiceProcessAdapter(service))
                        {
                            ServiceBase.Run(adapter);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionHelper.LogUnhandledException(exception);
            }
        }