public async Task Execute(BackgroundProcessContext context) { FetchJobData jobData = await _redisStorage.FetchNextJob(this._topic); if (jobData == null) { _redisStorage.WaitForJob(TimeSpan.FromMilliseconds(_options.ConsumePullIntervalMillisecond), context.CancellationToken); return; } if (context.IsShutdownRequested) { return; } var isSuccess = await DoWork(jobData); if (isSuccess) { await _redisStorage.SetSuccess(jobData.Topic, jobData.JobId); } else { await _redisStorage.SetFail(jobData.Topic, jobData.JobId); } }