Exemplo n.º 1
0
        private async Task <QueueClient> SetupTestQueue()
        {
            // Create and verify the existance of a queue. Pre-existing queues are ok to ignore.
            // Note that deleting domains does generate queues, so those tests can be negatively impacted if run at the same time.
            var         queueHelper = new QueueHelper(StorageConnectionString);
            QueueClient queueClient = await queueHelper.CreateQueue("testqueue");

            await QueueHelper.CheckIfQueueExistsWithRetry(queueClient);

            return(queueClient);
        }
Exemplo n.º 2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                await handler.Request();

                List <WorkerQueueItem> toprocess = new List <WorkerQueueItem>();

                if (handler.queue.Count > 0)
                {
                    toprocess.AddRange(handler.queue.ToList());
                    handler.queue.Clear();
                }

                var batches = QueueHelper.CreateQueue <WorkerQueueItem>(toprocess, threadcount);

                if (batches.Count > 0)
                {
                    handler.report.AddRange(GetInfo(batches));
                }

                var toupload = new List <WorkerReportItem>();

                if (handler.report.Count > 0)
                {
                    toupload.AddRange(handler.report.ToList());
                    handler.report.Clear();
                }

                if (toupload.Count > 0)
                {
                    await handler.ReportToAPI(toupload);
                }

                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                await Task.Delay(3000, stoppingToken);
            }
        }