views:

133

answers:

1

I'm writing a c# application that can create a series of request messages. Each message could have a response, that needs to be waited on by a consumer.

Where the number of outstanding request messages is constrained, I have used the windows EVENT to solve this problem. However, I know there is a limit on how many EVENT objects can be created in a single process, and in this instance, its possible I might exceed that limit.

Does anyone know if there is a similar limit on creation of mutex objects or semaphores?

I know this can be solved by some sort of pool of shared resources, that are grabbed by consumers when they need to wait, but it would be more convenient if each request message could have its own sync object.

+1  A: 

The system limits the total number of handles a process can create. Events, Mutexes, Semaphores etc. all contribute to the handle count so they will all be limited by the system.

That limit was 16*1024*1024, but I have been away from this stuff for a while so I do not know it it has changed with newer OSs and 64bit, but to be honest I doubt it since that is a huge number of handles to be creating, and probably constitutes a serious design flaw if you get anywhere near that.

Not having a very clear picture of what you are wanting, I might be wrong, but maybe you could look at something like the asyc event pattern? http://msdn.microsoft.com/en-us/library/wewwczdw.aspx

Chris Taylor