public async Task ProcessAsync(ProcessingContext context) { _logger.LogDebug("Publish Queuer start calling."); using (var scope = _provider.CreateScope()) { CapPublishedMessage sentMessage; var provider = scope.ServiceProvider; var connection = provider.GetRequiredService <IStorageConnection>(); while ( !context.IsStopping && (sentMessage = await connection.GetNextPublishedMessageToBeEnqueuedAsync()) != null) { var state = new EnqueuedState(); using (var transaction = connection.CreateTransaction()) { _stateChanger.ChangeState(sentMessage, state, transaction); await transaction.CommitAsync(); } } } context.ThrowIfStopping(); DefaultDispatcher.PulseEvent.Set(); await WaitHandleEx.WaitAnyAsync(PulseEvent, context.CancellationToken.WaitHandle, _pollingDelay); }
public async Task ProcessAsync(ProcessingContext context) { using (var scope = _provider.CreateScope()) { Job job; var provider = scope.ServiceProvider; var connection = provider.GetRequiredService <IStorageConnection>(); while ( !context.IsStopping && (job = await connection.GetNextJobToBeEnqueuedAsync()) != null) { var state = new EnqueuedState(); using (var transaction = connection.CreateTransaction()) { _stateChanger.ChangeState(job, state, transaction); await transaction.CommitAsync(); } } } context.ThrowIfStopping(); DelayedJobProcessor.PulseEvent.Set(); await WaitHandleEx.WaitAnyAsync(PulseEvent, context.CancellationToken.WaitHandle, _pollingDelay); }
public async Task ProcessCoreAsync(ProcessingContext context) { try { var worked = await Step(context); context.ThrowIfStopping(); Waiting = true; if (!worked) { var token = GetTokenToWaitOn(context); await WaitHandleEx.WaitAnyAsync(PulseEvent, token.WaitHandle, _pollingDelay); } } finally { Waiting = false; } }