c# - If you call EventWaitHandle.Set() X times, will it signal X threads if X the threads haven't started yet? -
In other words, I have a thread that starts and calls waitHandle.Set () Does several times. Then I start several threads and each one is waiting on that WaitHandle . They will be prompted for X, where x is the number of the number of the original thread called waitHandle.Set ()
, is there any structure that I try Do you complete more closely?
May be, but probably not.
Only set or unset an event, if there is nothing to unset the event, then repeating the call to set will not change its status, as long as this auto reset event And there is at least one thread waiting on it. Any threads (or start-up waiting) with manual reset event will be released until any events have gone bad without any problems.
I think that you really want a semaphore, in which there is a count and many times to release n threads (even if some thread only calls a few Start waiting to set up)
Comments
Post a Comment