C# Events Multiple Publishers to One Subscriber -
I have a code that has two event handlers, I want to inform these two event handlers another method That's something to do.
I have applied it through manual reset avenues, but I am sure what is the best way to achieve it, or if there is a better way.
Static Manual Reset Event AutoEvent = New Manual Retset (incorrect); Zero Start () {ThreadPool.QueueUserWorkItem (New WaitCallback (genericHandler)); } Zero OnEvent1 (object sender) {autoEvent.Set (); } Zero OnEvent2 (object sender) {autoEvent.Set (); } Zero generichandler (object information) {while (true) {autoEvent.WaitOne (); // do some work}}
I have one of the most important questions: After Is the best way to implement multiple publishers and one client pattern in C #? Or should I use another thing instead of manual reset? Note: Generic handler is in a separate thread because Event 1 and Event 2 have different preferences, so in the handler, I check whether the event1 is pending, before checking Event2. Your code actually does this that you think is such, and the race you describe The status problem of all, according to an MRE document, when it is set, it will remain in the "signal" status until the call is reset to autoEvent.WaitOne ()
, I do some work and this Work uses Pahl. Meanwhile, another incident has started, and set ()
is said before the normal handler WaitOne ()
again when WaitOne reaches again This will wait for another set ()
or set ()
is said before reaching WaitOne () when proceeding?
WaitOne
.
Comments
Post a Comment