/// <summary>
        /// Stops the engine and disposes all alarm sources and other plugins.
        /// </summary>
        internal void Stop()
        {
            if (!_isStarted)
            {
                return;
            }

            Logger.Instance.LogFormat(LogType.Info, this, Resources.EngineStopping);

            foreach (IAlarmSource alarmSource in _alarmSources)
            {
                try
                {
                    alarmSource.NewAlarm -= AlarmSource_NewAlarm;
                    alarmSource.Dispose();

                    if (_alarmSourcesThreads.ContainsKey(alarmSource))
                    {
                        Thread ast = _alarmSourcesThreads[alarmSource];
                        ast.Abort();

                        _alarmSourcesThreads.Remove(alarmSource);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, Resources.AlarmSourceDisposeException, alarmSource.GetType().FullName);
                    Logger.Instance.LogException(this, ex);
                }
            }

            _jobManager.Dispose();
            _jobManager = null;

            Logger.Instance.LogFormat(LogType.Info, this, Resources.EngineStopped);

            _isStarted = false;
        }
        /// <summary>
        /// Starts the monitor thread, which is waiting for a new Alarm.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Service start failed because of one of the following reasons. - There are no running alarm sources. - A general exception occurred.</exception>
        internal void Start()
        {
            if (_isStarted)
            {
                return;
            }

            Logger.Instance.LogFormat(LogType.Info, this, Resources.EngineStarting);

            InitializeAlarmSources();

            _jobManager = new JobManager(_serviceProvider);
            _jobManager.Initialize();

            int iInitializedSources = 0;
            foreach (IAlarmSource alarmSource in _alarmSources)
            {
                try
                {
                    Logger.Instance.LogFormat(LogType.Info, this, Resources.AlarmSourceInitializing, alarmSource.GetType().Name);
                    alarmSource.Initialize(_serviceProvider);
                    alarmSource.NewAlarm += AlarmSource_NewAlarm;

                    Thread ast = new Thread(AlarmSourceThreadWrapper);
                    ast.Priority = ThreadPriority.BelowNormal;
                    ast.Name = string.Format(AlarmSourceThreadNameFormat, alarmSource.GetType().Name);
                    ast.IsBackground = true;

                    _alarmSourcesThreads.Add(alarmSource, ast);
                    Logger.Instance.LogFormat(LogType.Info, this, Resources.AlarmSourceStarting, alarmSource.GetType().Name);
                    ast.Start(alarmSource);

                    iInitializedSources++;
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, Resources.AlarmSourceStartException, alarmSource.GetType().FullName);
                    Logger.Instance.LogException(this, ex);
                }
            }

            if (iInitializedSources > 0)
            {
                Logger.Instance.LogFormat(LogType.Info, this, Resources.EngineStarted);
                _isStarted = true;
            }
        }