In .NET Framework version 2.0 Web service proxy automatically creates for you
and includes a method named YourMethodNameAsync and an event named
YourMethodNameCompleted.
You can call YourMethodName asynchronously by registering a handler for
YourMethodNameCompleted events and calling YourMethodNameAsync, like this:
YourWebSvcProxy.YourMethodNameCompleted += new
YourMethodNameCompletedEventHandler (OnYourMethodNameCompleted);
YourWebSvcProxy.YourMethodNameAsync (YourObject);
....
void OnYourMethodNameCompleted (Object source,
YourMethodNameCompletedEventArgs e)
{
// This bit is Called after YourMethodName completes
}
So you call asynchronously your YourMethodNameAsync then after it finishes
whatever it do, it returns the call back to OnYourMethodNameCompleted.
Basically the same concepts apply to .NET 1.1 - you should create your own
asyncCall delegate and explicitly to start asynchronous call with
BeginYourMethodName and EndYourMethodName like this:
// Create a delegate to handle the callback
AsyncCallback asyncCall =
new AsyncCallback(OnYourMethodNameCompleted);
YourWebSvcProxy.BeginYourMethodName(YourObject, asyncCall, null);
private void OnYourMethodNameCompleted(IAsyncResult asyncResult)
{
// Get the Result of the WebMethod by calling
// the end method of the proxy class
YourObject YourResult = YourWebSvcProxy.EndYourMethodName(asyncResult);
}
--
Yotov, Valko
MCSD.NET, MCAD.NET, MCDBA 2000, MCP NT/2000
-------------------------------
"Live as if you were to die tomorrow. Learn as if you were to live forever."
-- Ghandi
[quoted text, click to view] "jeff@cumpsty.co.uk" wrote:
> I need to turn an asyncronous call into a syncronous one.
>
> I have a Web Applicaition which makes a call to web services to
> retrieve data.
>
> A new web service that I need to support work asyncronously...sort
> of. The way it is set up is I make a call into a third party web
> service, and get a job reference returned. About 5 seconds later the
> third party calls into a web service which I provide with a response.
>
> I want my application to call the web service and then go to sleep.
> When my web service is called my thread can return the my web app.
>
> Does anyone know how this can be done?
>
> THanks
>