about BeginInvoke and EndInvoke

  • Thread starter Thread starter Jet Leung
  • Start date Start date
J

Jet Leung

Hi All,
There is a problem about asynchronism process.If I run the method by
BeginInvoke() and how can I know when the method is finish? And maybe I can
say when I can use EndInvoke()?
 
BeginInvoke executes a delegate asynchronously on the thread that the
control's underlying handle was created on, you can then query the
(IAysncResult) interface returned by the method to see if the asynchronous
call has completed, when the asynchronous operation has completed you then
use EndInvoke to retrieve the result of the asynchronous operation.

Hope this helps

Ollie
 
Jet Leung said:
There is a problem about asynchronism process.If I run the method by
BeginInvoke() and how can I know when the method is finish?

You can specify a callback delegate which is executed after the method
has finished.
And maybe I can say when I can use EndInvoke()?

You can use EndInvoke at any time, but it will block until the delegate
has finished executing.

See http://www.pobox.com/~skeet/csharp/multithreading.html#async
for more information.
 
Back
Top