I'm trying to create a processing component that simply has a queue of objects that it has to process. I'm trying to create a worker thread that simply processes the queue as long as something is in it and pauses or sleeps until something else is placed in the queue. The problem I'm having is finding the best way of doing it. I've thought about having the thread sleep and check occationally if something has been added, but that just seems like a waste. I've looked at Thread.Suspend and Thread.Resume, but MSDN suggests that I should use Monitor.Wait for this type of activity because Suspend and Resume shouldn't be used in this matter but I feel that it's far too complicated for this simple issue. I think I'm just missing something. Somebody out there has had to have done something like this before. Any help?
Question
MrRogers
I'm trying to create a processing component that simply has a queue of objects that it has to process. I'm trying to create a worker thread that simply processes the queue as long as something is in it and pauses or sleeps until something else is placed in the queue. The problem I'm having is finding the best way of doing it. I've thought about having the thread sleep and check occationally if something has been added, but that just seems like a waste. I've looked at Thread.Suspend and Thread.Resume, but MSDN suggests that I should use Monitor.Wait for this type of activity because Suspend and Resume shouldn't be used in this matter but I feel that it's far too complicated for this simple issue. I think I'm just missing something. Somebody out there has had to have done something like this before. Any help?
Link to comment
Share on other sites
4 answers to this question
Recommended Posts