Here is a code snippet from Microsoft. I have a doubt in asynchronous method calling.
since we are calling end.Invoke after Begin-invoke it is looks like we are doing a synchronous call. because we are waiting for the returned value of asynchronous call.
what happens if the asynchronous method didn't completes while we are calling end.invoke. can we just proceed to next statement or we have to wait.
if this is happening in multithreaded environment how they are handling callback signal to correct thread.
public void DemoEndInvoke()
{
MethodDelegate dlgt = new MethodDelegate (this.LongRunningMethod) ;
string s ;
int iExecThread;
// Initiate the asynchronous call.
IAsyncResult ar = dlgt.BeginInvoke(3000, out iExecThread, null, null);
// Do some useful work here. This would be work you want to have
// run at the same time as the asynchronous call.
// Retrieve the results of the asynchronous call.
s = dlgt.EndInvoke (out iExecThread, ar) ;
MessageBox.Show (string.Format ("The delegate call returned the string: \"{0}\",
and the number {1}", s, iExecThread.ToString() ) );
}