/// <summary> /// Initializes a new instance of the <see cref="BackgroundProcessingServer"/> /// class and immediately starts all the given background processes. /// </summary> internal BackgroundProcessingServer( [NotNull] BackgroundServerProcess process, [NotNull] BackgroundProcessingServerOptions options) { _process = process ?? throw new ArgumentNullException(nameof(process)); _options = options ?? throw new ArgumentNullException(nameof(options)); _dispatcher = CreateDispatcher(); #if !NETSTANDARD1_3 AppDomain.CurrentDomain.DomainUnload += OnCurrentDomainUnload; AppDomain.CurrentDomain.ProcessExit += OnCurrentDomainUnload; #endif _shutdownRegistration = AspNetShutdownDetector.GetShutdownToken().Register(OnAspNetShutdown); }