jeudi 16 mars 2017

How can I create a collection of items that

Let me try to explain the design pattern I'm looking to implement. I have a Queue<Item> or some other collection of Items that needs to be processed by some method

static void Process(Item item) 
{
   // ... 
} 

They can be processed synchronously or asynchronously.

This queue will be getting items added to it periodically, because I have some method like

static void AddWorkToQueue()
{
   // ... 
}

that gets run on a timer

timer.Elapsed += AddWorkToQueue();

So what I need is some type "continuous while loop" that stops whenever the queue is empty.

How can I use C#.NET to do this in the best way? Are there any built-in libraries for solving this type of problem?

Aucun commentaire:

Enregistrer un commentaire