Esempio n. 1
0
        /// <summary>
        /// Stops the Thread.
        /// </summary>
        public void Stop()
        {
            if (!IsStarted)
            {
                return;
            }

            Logger.Instance.LogFormat(LogType.Info, this, "Stopping Service");

            // Dispose and kill all threads
            foreach (IAlarmSource alarmSource in _alarmSources)
            {
                try
                {
                    // Unregister from event and dispose source
                    alarmSource.NewAlarm -= AlarmSource_NewAlarm;
                    alarmSource.Dispose();

                    // Stop and remove the thread
                    Thread ast = _alarmSourcesThreads[alarmSource];
                    // Abort and ignore exception
                    ast.Abort();

                    _alarmSourcesThreads.Remove(alarmSource);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, "Error disposing alarm source '{0}'.", alarmSource.GetType().FullName);
                    Logger.Instance.LogException(this, ex);
                }
            }

            // TODO: Dispose jobs!
            _jobs.Clear();

            // Dispose operation store
            _operationStore = null;
            // Dispose route plan provider
            _routePlanProvider = null;

            Logger.Instance.LogFormat(LogType.Info, this, "Stopped Service");

            IsStarted = false;
        }
Esempio n. 2
0
 private void InitializeRoutePlanProvider()
 {
     _routePlanProvider = ExportedTypeLibrary.Import <IRoutePlanProvider>(AlarmWorkflowConfiguration.Instance.RoutePlanProviderAlias);
     Logger.Instance.LogFormat(LogType.Info, this, "Using route plan provider '{0}'.", _routePlanProvider.GetType().FullName);
 }
 private void InitializeRoutePlanProvider()
 {
     _routePlanProvider = ExportedTypeLibrary.Import<IRoutePlanProvider>(AlarmWorkflowConfiguration.Instance.RoutePlanProviderAlias);
     Logger.Instance.LogFormat(LogType.Info, this, "Using route plan provider '{0}'.", _routePlanProvider.GetType().FullName);
 }
        /// <summary>
        /// Stops the Thread.
        /// </summary>
        public void Stop()
        {
            if (!IsStarted)
            {
                return;
            }

            Logger.Instance.LogFormat(LogType.Info, this, "Stopping Service");

            // Dispose and kill all threads
            foreach (IAlarmSource alarmSource in _alarmSources)
            {
                try
                {
                    // Unregister from event and dispose source
                    alarmSource.NewAlarm -= AlarmSource_NewAlarm;
                    alarmSource.Dispose();

                    // Stop and remove the thread
                    Thread ast = _alarmSourcesThreads[alarmSource];
                    // Abort and ignore exception
                    ast.Abort();

                    _alarmSourcesThreads.Remove(alarmSource);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Warning, this, "Error disposing alarm source '{0}'.", alarmSource.GetType().FullName);
                    Logger.Instance.LogException(this, ex);
                }
            }

            // TODO: Dispose jobs!
            _jobs.Clear();

            // Dispose operation store
            _operationStore = null;
            // Dispose route plan provider
            _routePlanProvider = null;

            Logger.Instance.LogFormat(LogType.Info, this, "Stopped Service");

            IsStarted = false;
        }