Hi. In my other recent post - [C#] - lock(...) and new Thread - I show how I am letting a client start/pause/resume a class that is doing work using threads it spawns off.
I have seen other alternatives to my method which use the ManualResetEvent to block the thread rather than to actually stop it (save work state) and then start up a new thread when the client calls Resume().
I just wanted to know if anyone knows the various advantages between the two alternatives. It seems to me that using ManualResetEvent is wasteful as it just leaves a Thread sleeping/blocked rather than actually releasing the thread as my current method does. On the other hand, the ManualResetEvent looks easier to implement and also seems like a more standard approach (though I've done no research into the matter).
Question
ProChefChad
Hi. In my other recent post - [C#] - lock(...) and new Thread - I show how I am letting a client start/pause/resume a class that is doing work using threads it spawns off.
I have seen other alternatives to my method which use the ManualResetEvent to block the thread rather than to actually stop it (save work state) and then start up a new thread when the client calls Resume().
I just wanted to know if anyone knows the various advantages between the two alternatives. It seems to me that using ManualResetEvent is wasteful as it just leaves a Thread sleeping/blocked rather than actually releasing the thread as my current method does. On the other hand, the ManualResetEvent looks easier to implement and also seems like a more standard approach (though I've done no research into the matter).
Thanks for your advice.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts