Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
today someone told me that when using the async pattern it is possible to use
C#
public DataTable EndCall(IAsyncResult ar)

in stead of
C#
public void EndCall(IAsyncResult ar)

is this true? because in the BeginEventHandler an error is given.

In this case a HttpModule is used. That registers the begin and end handler in IIS and IIS handles the async call. This async httpmodule calls a proxy class and that call a wcf service. Even the proxy has generated async methods based on the methods in the wcf service.
Posted
Updated 28-Sep-11 20:59pm
v4
Comments
Jimmanuel 28-Sep-11 14:48pm    
If you're implementing the Async method yourself then yes it's possible, but more info would be needed to diagnose your exact problem. What's the error? More code please.
Ed Nutting 28-Sep-11 16:02pm    
Agree with Jimmanuel - it depends very much on situation - like most things really :)

1 solution

Yes it is possible to get a return value when using async methods. So if we had a method such as ..

C#
private string Foo()
{
  return "Hello"
}


and a delagate like this ..

C#
public delegate string MyDelegate();


You can use code like this to get the result.

C#
MyDelegate del = new MyDelegate();
IAsyncResult res = del.BeginInvoke();

// Do something while our method is being executed

string result = delFoo.EndInvoke(res);
 
Share this answer
 
Comments
RaisKazi 29-Sep-11 7:39am    
Good Answer. My 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900