I have an application that need control many slave processes to do the task. And there is a matching thread to do the match job. I use EventWaitHandle to communicate between them, at free time the matching thread is wait for slave's event, the code is like:
EventWaitHandle.WaitAny(GetWaitEvents());
//GetWaitEvents method will return all slave process's EventWaitHandle
In the slave process, once it is free. It will trigger the event to match another task to this process. Code like:
ProxyEvent.Set()
However, when the number of the event exceed 64, it will throw System.NotSupportedException. After checking the code get from the Microsoft, I found it is hard code in the framwork code:
private const int MAX_WAITHANDLES = 64;
My question is:
- Why it have such limit? Why 64?
- Is there any workaound for this limit?