opensubscriber
   Find in this group all groups
 
Unknown more information…

d : dotnet-winforms@discuss.develop.com 16 January 2008 • 1:17AM -0500

Delegate.BeginInvoke and EndInvoke.
by Bhatnagar, Amit

REPLY TO AUTHOR
 
REPLY TO GROUP



I have made a service to timeout a method call by launching a delegate
asynchronously via BeginInvoke. The documentation states, indirectly,
that the call to BeginInvoke should be followed by a call to EndInvoke
to prevent leaks. However, I am not sure if the call to EndInvoke is
required should the delegate timeout because the call to EndInvoke will
block the thread and wait for the delegate to complete. So I think what
I have is OK, but can anyone confirm if the call to EndInvoke is
required if it timesout?

See the following code:

---
IAsyncResult asyncResult = d.BeginInvoke(null, new object());

if (asyncResult.AsyncWaitHandle.WaitOne(7000, true))
{
   // Not timed out...
   d.EndInvoke(asyncResult);
}

else
{
   //Timed out ... EndInvoke required here?
}

The information contained in this e-mail message is PRIVATE. It may contain confidential information and may be legally privileged. It is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any dissemination, distribution or reproduction of this communication is strictly prohibited. If the intended recipient(s) cannot be reached or if a transmission problem has occurred, please notify the sender immediately by return e-mail and destroy all copies of this message.
Thank you.

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.