开发者

What is the easiest way to pause Consumer in P-C pattern?

开发者 https://www.devze.com 2023-03-06 03:21 出处:网络
I have typical producer-consumer application. I have BlockingCollection to provide producing-consuming mechanism. What I need is to add ability to pause consumer thread execution fr开发者_如何学JAVAom

I have typical producer-consumer application. I have BlockingCollection to provide producing-consuming mechanism. What I need is to add ability to pause consumer thread execution fr开发者_如何学JAVAom another thread. I've read about different .net synchronization primitives but I can't decide how to implement it in the easiest way.

P.S.: I use .net 4.0.


Use an AutoResetEvent and wait on it in the Consumer until the other thread wakes it up again, by setting it to signaled.

0

精彩评论

暂无评论...
验证码 换一张
取 消