Re: Delegate.BeginInvoke and EndInvoke.
"Bhatnagar, Amit" <[email protected]> Tue, 15 Jan 2008 12:33:45 -0700
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <[email protected]> |
The AsyncCallback doesn't get called if the delegate times out, so there is no way to call EndInvoke.=20 Is my only option then to create another thread and wait for a signal and then call EndInvoke like you suggested in your previous post? An example of that scenario would be handy.=20 How bad would not calling EndInvoke in the timed-out case really be? -----Original Message----- From: Discussion forum for developers using Windows Forms to build apps and controls [mailto:[email protected]] On Behalf Of Peter Ritchie Sent: Tuesday, January 15, 2008 11:43 AM To: [email protected] Subject: Re: [DOTNET-WINFORMS] Delegate.BeginInvoke and EndInvoke. In Richard's example (pg 2), he shows using the BeginInvoke overload that takes the AsyncCallback which calls some method when the call completes. In there, as Richard details, you can call EndInvoke. The AsyncCallback is called on a ThreadPool thread. If you're looking to avoid stress on the threadpool, using your own thread to wait on the wait handle may be a better option. Using the AsyncCallback means creating a type to keep track of the delegate reference in order to call its BeginInvoke. It's up to you how complicated you want to be if stressing the threadpool isn't an issue. Peter's example has a leak. 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.=20 Thank you.=20