Exemplo n.º 1
0
        public void Stop()
        {
            lock (timer)
            {
                if (Status != BackgroundServiceExecutorStatus.Stopped)
                {
                    timer.Change(Timeout.Infinite, Timeout.Infinite);
                    timer.Dispose();

                    current = null;

                    Status = BackgroundServiceExecutorStatus.Stopped;
                }
            }
        }
Exemplo n.º 2
0
        public void Start()
        {
            lock (timer)
            {
                if (Status == BackgroundServiceExecutorStatus.Paused || Status == BackgroundServiceExecutorStatus.Stopped)
                {
                    if (Status == BackgroundServiceExecutorStatus.Stopped)
                    {
                        Status = BackgroundServiceExecutorStatus.Starting;

                        current = (IBackgroundService)container.Resolve(backgroundServiceType);
                        current.Initialize(moduleConfiguration);
                    }

                    Status = BackgroundServiceExecutorStatus.Running;

                    current.Run(moduleConfiguration);

                    timer.Change(interval, new TimeSpan(0, 0, 0, 0, -1));
                }
            }
        }