Asynchronously calling WCF using C #?

In C #, how do I make an asynchronous call to a WCF web service? I have a Service Reference configured to generate async. I also changed my calls to use {WebServiceObject.Begin * ()}, but at the end there are two parameters: "AsyncCallback" and "Object asyncState". What is it and how to use them?

Thanks,

+4
source share
3 answers

See MSDN Here; http://msdn.microsoft.com/en-us/library/system.asynccallback.aspx

here; http://msdn.microsoft.com/en-us/library/ms228969.aspx

here; http://msdn.microsoft.com/en-us/library/ms228975.aspx

and here; http://msdn.microsoft.com/en-us/library/86wf6409.aspx

Basically in Begin * you set up a callback, the calling call is called when the operation is completed. There you call End * to get the relevant data.

+3
source

You can also watch Async without the Pain

+4
source

A callback is called when the operation is completed, so you can call End * and get a return value or exception, if any. asyncState is just the value to match in the callback if you use the same callback method in multiple places. Here is a description of the Async design pattern - http://msdn.microsoft.com/en-us/library/aa719595(VS.71).aspx

If you are creating a GUI application, consider using a different version - * Async method, which is created for each operation. It provides thread synchronization.

+2
source

All Articles