Async call to WCF with C#?

前端 未结 3 1952
孤街浪徒
孤街浪徒 2020-12-18 09:03

In C#, how do I make an async call to a WCF Web Service? I have a Service Reference set up to generate async. I also modified my calls to use { WebServiceObject.Begin* () }

3条回答
  •  伪装坚强ぢ
    2020-12-18 09:41

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

    If you are creating GUI application, consider using another version - *Async method which is generated for each operation as well. It provides thread synchronization.

提交回复
热议问题