示例#1
0
        public async Task <ActionResult> Get()
        {
            var reportId = Request.ExtractReportId();

            _progress.Report(new ActionReport {
                Text = "Starting the request..."
            }, reportId);
            await Task.Delay(1000);

            _progress.Report(new ActionReport {
                Text = "First step ok!"
            }, reportId);
            await Task.Delay(1000);

            _progress.Report(new ActionReport {
                Text = "Request done!"
            }, reportId);

            return(Ok());
        }
示例#2
0
        public async Task Consume(BackgroundJobData obj, MessageContext context, CancellationToken cancellationToken)
        {
            _logger.LogWarning("Starting background job...");

            var       reportId = context.ExtractReportId();
            const int Count    = 10;

            for (var i = 1; i <= Count; i++)
            {
                var report = new BackgroundJobReport
                {
                    Count   = Count,
                    Current = i
                };

                _progress.Report(report, reportId);
                await Task.Delay(500);
            }

            _logger.LogWarning("Finished background job!");
        }