Exemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var thread = new Thread(async() =>
            {
                WorkerLog.Instance.Information($"Starting {nameof(FileChunkReceiverWorker)}");
                var incomingQueue = _workerQueueContainer.ReceivedChunks.Reader;
                while (await incomingQueue.WaitToReadAsync() || !stoppingToken.IsCancellationRequested)
                {
                    var fileChunk = await incomingQueue.ReadAsync();
                    await _fileChunkRepository.AddReceivedFileChunk(fileChunk);
                }
            });

            thread.Start();
            await Task.Delay(Timeout.Infinite);
        }