I have a question, and I could do with some code examples to help me, and I feel it may help to give some background.
I have the need to create an engine of 3 Queues (in C#, winforms). The 3 Queues merely contain an “action” object. Actions get thrown into the engine, and stick themselves to the “most available” Queue (basically, the Queue with the lowest count). Almost all of the time the Queues can run discretely and asynchronously with no harm. However there is one “Action” situation which may happen, and when that type of “Action” occurs and does bubble to the front of a Queue, it must :
- wait for the other queues to stop their current actions
- lock/pause them when they are finished on their current Action
- run the Action alone until it finishes
- release the lock on the other 2 queues.
With the added issue that any of the 3 queues can lock the other 2.
Does anyone have any experience of this?
I hope so, it seems a bit painful 🙂 Thanks in advance
This is a combination of the single queue approach recommended by Servy and the
ReaderWriterLocksuggestion by Casperah.