protected ConsoleApplicationEntryPointBase([NotNull] ILogger logger, [NotNull] IBus bus, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); Bus = bus ?? throw new ArgumentNullException(nameof(bus)); _CtrlCCancellationTokenSource = new CancellationTokenSource(); }
public StopWindowsServiceCommand( [NotNull] IWindowsServiceController windowsServiceController, [NotNull] ILogger logger, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _WindowsServiceController = windowsServiceController ?? throw new ArgumentNullException(nameof(windowsServiceController)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); }
public BackgroundServiceMonitor( [NotNull] IFeatureToggleWithDefault featureToggle, [NotNull] IBackgroundService backgroundService, [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger, [NotNull] ITypeHelper typeHelper) { _FeatureToggle = featureToggle ?? throw new ArgumentNullException(nameof(featureToggle)); _BackgroundService = backgroundService ?? throw new ArgumentNullException(nameof(backgroundService)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _TypeHelper = typeHelper ?? throw new ArgumentNullException(nameof(typeHelper)); }
public TrayApp( [NotNull] IBackgroundServicesManager backgroundServicesManager, [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger) { _BackgroundServicesManager = backgroundServicesManager ?? throw new ArgumentNullException(nameof(backgroundServicesManager)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public RunAsServiceCommand( [NotNull] ILogger logger, [NotNull] IWindowsServiceConfiguration configuration, [NotNull] IBackgroundServicesManager backgroundServicesManager, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _BackgroundServicesManager = backgroundServicesManager ?? throw new ArgumentNullException(nameof(backgroundServicesManager)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); }
public GCTracker([NotNull] IPerformanceCounter gcCounter, [NotNull] List <IPerformanceCounter> gcCounters, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _GcCounter = gcCounter ?? throw new ArgumentNullException(nameof(gcCounter)); _GcCounters = gcCounters ?? throw new ArgumentNullException(nameof(gcCounters)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); for (int index = 0; index < _GcCounters.Count; index++) { _PreviousValues.Add(GC.CollectionCount(index)); } }
public WebServer( [NotNull] IContainer container, [NotNull] IApplicationContext applicationContext, [NotNull, ItemNotNull] IEnumerable <IConfigurationConfigurator> configurationConfigurators, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { if (configurationConfigurators == null) { throw new ArgumentNullException(nameof(configurationConfigurators)); } _Container = container ?? throw new ArgumentNullException(nameof(container)); _ApplicationContext = applicationContext ?? throw new ArgumentNullException(nameof(applicationContext)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _ConfigurationConfigurators = configurationConfigurators.ToList(); }
public TrayIconBackgroundService( [NotNull] IEnumerable <ITrayIconMenuItem> menuItems, [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger) { if (menuItems == null) { throw new ArgumentNullException(nameof(menuItems)); } _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _MenuItems = menuItems.ToList(); }
public WindowsService( [NotNull] IWindowsServiceConfiguration configuration, [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] IBackgroundServicesManager backgroundServicesManager, [NotNull] ILogger logger) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } _BackgroundServicesManager = backgroundServicesManager ?? throw new ArgumentNullException(nameof(backgroundServicesManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); ServiceName = configuration.ServiceName; CanStop = true; }
public CommandBasedApplicationEntryPoint( [NotNull, ItemNotNull] IEnumerable <IApplicationCommand> commands, [NotNull] IConfiguration configuration, [NotNull] IConsoleApplicationHelpTextPresenter helpTextPresenter, [NotNull] ILogger logger, [NotNull] IBus bus, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) : base(logger, bus, applicationLifetimeManager) { if (commands == null) { throw new ArgumentNullException(nameof(commands)); } _Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _HelpTextPresenter = helpTextPresenter ?? throw new ArgumentNullException(nameof(helpTextPresenter)); _Commands = commands.ToList(); }
public ConsoleApplicationEntryPoint( [NotNull] IApplicationEntryPoint applicationEntryPoint, [NotNull] ILogger logger, [NotNull] IBackgroundServicesManager backgroundServicesManager, [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] IConfiguration configuration, [NotNull] IConsoleApplicationHelpTextPresenter consoleApplicationHelpTextPresenter, [NotNull] IBus bus) : base(logger, bus, applicationLifetimeManager) { _ApplicationEntryPoint = applicationEntryPoint ?? throw new ArgumentNullException(nameof(applicationEntryPoint)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _ConsoleApplicationHelpTextPresenter = consoleApplicationHelpTextPresenter ?? throw new ArgumentNullException(nameof(consoleApplicationHelpTextPresenter)); _BackgroundServicesManager = backgroundServicesManager ?? throw new ArgumentNullException(nameof(backgroundServicesManager)); }
public BackgroundServicesManager( [NotNull, ItemNotNull] IEnumerable <IBackgroundService> backgroundServices, [NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger, [NotNull] ITypeHelper typeHelper, [NotNull] IFeatureToggles featureToggles) { if (backgroundServices == null) { throw new ArgumentNullException(nameof(backgroundServices)); } _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); _TypeHelper = typeHelper ?? throw new ArgumentNullException(nameof(typeHelper)); _FeatureToggles = featureToggles ?? throw new ArgumentNullException(nameof(featureToggles)); _BackgroundServices = backgroundServices.ToList(); }
public PidQuitFileMonitorBackgroundService([NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger) { _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public ExitTrayIconAppMenuItem([NotNull] IApplicationLifetimeManager applicationLifetimeManager, [NotNull] ILogger logger) { _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); _Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public SystemPerformanceCounters([NotNull] IPerformanceCounters performanceCounters, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _PerformanceCounters = performanceCounters ?? throw new ArgumentNullException(nameof(performanceCounters)); _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); }
public DaemonApplicationEntryPoint([NotNull] ILogger logger, [NotNull] IBus bus, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) : base(logger, bus, applicationLifetimeManager) { }
public static void RunWinFormsMainWindow <T>(bool useBackgroundServices) where T : class, IServicesBootstrapper { var container = ContainerFactory.Bootstrap <ServicesBootstrapper <T> >(); IBackgroundServicesManager backgroundServicesManager = container.Resolve <IBackgroundServicesManager>().NotNull(); IApplicationLifetimeManager applicationLifetimeManager = container.Resolve <IApplicationLifetimeManager>(); if (useBackgroundServices) { backgroundServicesManager.StartBackgroundServices(); } try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form mainForm = container.Resolve <Form>(serviceKey: "MainForm"); bool closingHasBeenHandled = true; applicationLifetimeManager.GracefulTerminationCancellationToken.Register( () => { if (closingHasBeenHandled) { return; } closingHasBeenHandled = true; var close = new Action(() => mainForm.Close()); if (mainForm.InvokeRequired) { mainForm.BeginInvoke(close); } else { close(); } }); mainForm.FormClosed += (s, e) => { closingHasBeenHandled = true; applicationLifetimeManager.SignalGracefulTermination(); }; Application.Run(mainForm); } catch (Exception) when(!Debugger.IsAttached) { Environment.ExitCode = 1; throw; } finally { if (useBackgroundServices) { backgroundServicesManager.WaitForBackgroundServicesToStop().GetAwaiter().GetResult(); } } }
public ApplicationShutdownBackgroundService([NotNull] ILogger logger, [NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _Logger = logger; _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); }
public StopApplicationCommandHandler([NotNull] IApplicationLifetimeManager applicationLifetimeManager) { _ApplicationLifetimeManager = applicationLifetimeManager ?? throw new ArgumentNullException(nameof(applicationLifetimeManager)); }