Open
Description
For something like the following:
public class QueueProcessor { private readonly BlockingCollection _messageQueue = new BlockingCollection(); public void StartProcessing() { //Start background processing here. What's the best approach? } public void Enqueue(Message message) { _messageQueue.Add(message); } private async Task ProcessQueue() //notice the async Task here { foreach (var item in _messageQueue.GetConsumingEnumerable()) { await ProcessItem(item).ConfigureAwait(false); } } private async Task ProcessItem(Message message) { } }
What is the best approach of executing the long running work in the background? I have looked everywhere and I've found a lot of contradicting advice on this.
Metadata
Assignees
Labels
No labels
Activity