Re: Delegate.BeginInvoke and EndInvoke.

Peter Ritchie <[email protected]> Tue, 15 Jan 2008 13:43:23 -0500
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <LISTSERV%[email protected]>
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.