Asynchronous Delegates

  • Thread starter Thread starter Tobias Matzat
  • Start date Start date
T

Tobias Matzat

Hi!

Is it possible to wait for the callback method to finish? When using a
WaitHandle only the call of EndInvoke is awaited. I would like to do
some calculations in the callback-method. But I don't know how to inform
the main thread that the calculations are done, besides defining an
event. Is it not possible to let the callback method do the work? Or am
I getting something wrong?

THX!
Tobias
 
Tobias,

You should let the callback method do your work. This will be on a
thread other than the main thread that the BeginInvoke was called on.

If you need to notify your main thread (which I assume is your UI
thread), then create a method that will serve as a callback for a delegate
you define. Then, in your callback method, when the calcs are done, call
the Invoke method on the form/control on the UI thread, passing a delegate
that wraps the method to be called.

Hope this helps.
 
Back
Top