/// <summary> /// Initializes a new instance of the <see cref="BackgroundCommandEventRepositoryDispatcherDecorator"/> class. /// </summary> /// <param name="wrappedDispatcher">The wrapped <see cref="IBackgroundDispatcher"/>.</param> /// <param name="repository">The <see cref="IBackgroundCommandEventRepository"/>.</param> public BackgroundCommandEventRepositoryDispatcherDecorator( IBackgroundDispatcher wrappedDispatcher, IBackgroundCommandEventRepository repository) { _wrappedDispatcher = wrappedDispatcher ?? throw new ArgumentNullException(nameof(wrappedDispatcher)); _repository = repository ?? throw new ArgumentNullException(nameof(repository)); }
public async Task <IActionResult> DispatchCommand( [FromServices] IBackgroundDispatcher dispatcher) { var command = new SampleCommand(); await dispatcher.DispatchAsync(command); return(AcceptedAtRoute(nameof(GetCommandStatus), new { id = command.Id })); }
/// <summary> /// Initializes a new instance of the <see cref="TelemetryClientDispatcherDecorator"/> class. /// </summary> /// <param name="wrappedDispatcher">The inner <see cref="IBackgroundDispatcher"/>.</param> /// <param name="options">The <see cref="TelemetryClientDecoratorOptions"/>.</param> /// <param name="telemetryClient">The <see cref="TelemetryClient"/>.</param> public TelemetryClientDispatcherDecorator( IBackgroundDispatcher wrappedDispatcher, IOptions <TelemetryClientDecoratorOptions> options, TelemetryClient telemetryClient) { _wrappedDispatcher = wrappedDispatcher ?? throw new ArgumentNullException(nameof(wrappedDispatcher)); _options = options ?? throw new ArgumentNullException(nameof(options)); _telemetryClient = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient)); }
/// <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 }
/// <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(Dispose); }