/// <summary> /// Start all services and start monitoring them. /// </summary> /// <exception cref="System.AggregateException"> /// Contains one or more <see cref="StartServiceException" /> with information about the services that could not be /// started. /// </exception> public void Start() { var exceptions = new List <Exception>(); var services = _serviceLocator.GetServices(); foreach (var service in services) { var guarded = service as IGuardedService; if (guarded != null) { guarded.Failed += OnServiceFailed; } if (!IsEnabled(service.GetType())) { Signals.Signal.Raise("ApplicationServices[" + service.GetType().FullName + "].Disabled", "Disabled through configuration."); _logger.Debug("Service is disabled '" + service.GetType().FullName + "'."); continue; } Signals.Signal.Reset("ApplicationServices[" + service.GetType().FullName + "].Disabled"); try { _logger.Info("Starting service '" + service.GetType().FullName + "'."); service.Start(); Signals.Signal.Reset("ApplicationServices[" + service.GetType().FullName + "].Faulted"); Signals.Signal.Raise("ApplicationServices[" + service.GetType().FullName + "].Started", "Started through ApplicationserviceManager.Start()."); } catch (Exception exception) { Signals.Signal.Raise("ApplicationServices[" + service.GetType().FullName + "].Faulted", exception.Message, exception); exceptions.Add(new StartServiceException(service, exception)); } } _timer.Change(StartInterval, CheckInterval); if (exceptions.Any()) { throw new AggregateException(exceptions); } }
/// <summary> /// Start all services and start monitoring them. /// </summary> /// <exception cref="System.AggregateException"> /// Contains one or more <see cref="StartServiceException" /> with information about the services that could not be /// started. /// </exception> public void Start() { var exceptions = new List <Exception>(); var services = _serviceLocator.GetServices(); foreach (var service in services) { var guarded = service as IGuardedService; if (guarded != null) { guarded.Failed += OnServiceFailed; } if (!IsEnabled(service.GetType())) { _logger.Debug("Service is disabled '" + service.GetType().FullName + "'."); continue; } try { _logger.Info("Starting service '" + service.GetType().FullName + "'."); service.Start(); } catch (Exception exception) { exceptions.Add(new StartServiceException(service, exception)); } } _timer.Change(StartInterval, CheckInterval); if (exceptions.Any()) { throw new AggregateException(exceptions); } }