Couldn't find any info in the archives on this:

Env: XP Pro/dual proc machine/C# Windows Forms/.NET SP2.

Has anyone used ThreadPool.RegisterWaitForSingleObject? I have found
that providing the same AutoResetEvent instance to this method with a
subsequent unregister followed by a re-register, I get different
behavior.

The actual sequence is this: ThreadPool.RegisterWaitForSingleObject,
RegisteredWaitHandle.Unregister, followed by a
ThreadPool.RegisterWaitForSingleObject reusing the same AutoResetEvent

In my tests, I gave ThreadPool.RegisterWaitForSingleObject the following
parameters:
same instance of AutoResetEvent, a string state obj, TimeSpan=10
seconds, bool true.

I've tested this waiting for the timeout to occur and also signalling
the AutoResetEvent prior to the timeout.

After the first time register this works as expected, all subsequent
re-registers following the steps above, the delegate target is
immediately invoked with the timeout == false. The Unregister return
always returns true.

I have found that this all works fine, if I pass a new instance of
AutoResetEvent on every RegisterWaitForSingleObject.

Why, the different behavior using the same AutoResetEvent instance for
RegisterWaitForSingleObject?

Thanks,
-Jeff WS

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
You may be interested in Guerrilla .NET, 24 March 2003, in London
http://www.develop.com/courses/gdotnet

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

Reply via email to