No.  This is a design constraint of the NT kernel.  Each thread has a
block of wait handle pointers in its KTHREAD structure, and that block
has a finite length.

The reason that it is relatively small, is that WaitForMultipleObjects
becomes more expensive when you have more handles involved.  This is
because the NT Object Manager must validate each handle, and translate
each handle to an internal object pointer, every time you call
WaitForMultipleObjects (which is the Win32 call behind
WaitHandle.WaitAny).  Then, when the call completes, the NT Object
Manager must enumerate that list again, and release every pointer.

For a "handful" of wait handles, this is acceptable.  However, for a
significant set of wait handles, it is bad design -- bad *application*
design.  The 64 handle limit is a hint to you, that you should be using
some other notification mechanism, one that efficiently supports
notification events from many different sources.  Under Win32, there are
many different mechanisms to choose from: I/O completion ports, APCs,
etc.

If you are using this for intra-process synchronization, then you could
consider using a small number of synchronization objects to implement a
notification queue, or whatever suits your application.

Unfortunately, some of the more advanced notification mechanisms in NT
are not directly exposed to .Net applications.  With some digging and
DllImport'ing, you can usually get to most of them.  Also, you could
consider writing this portion of your app in Managed C++, since that
will let you get access to the Win32 SDK in a much more seemless
fashion.

-- arlie


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Andrew Chalk
Sent: Saturday, November 01, 2003 9:06 PM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] WaitHandle.WaitAny Limitations


WaitHandle.WaitAny has a limitation of 64 events. Is there any way
around this limitation (for example, a systemwide parameter change or
alternative synchronization method)?

Many thanks

===================================
This list is hosted by DevelopMentorR  http://www.develop.com Some .NET
courses you may be interested in:

Guerrilla ASP.NET, 10 Nov 2003 in London and 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnet

Guerrilla .NET, 8 Dec 2003, in Los Angeles
http://www.develop.com/courses/gdotnet

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

Guerrilla ASP.NET, 10 Nov 2003 in London and 26 Jan 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnet

Guerrilla .NET, 8 Dec 2003, in Los Angeles
http://www.develop.com/courses/gdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to