如果wcf服務設計如下方式,請引導我如何從客戶端調用Add()
函數Asynchronously
。感謝如何異步調用wcf服務
[ServiceContract]
public interface IAddTwoNumbers
{
// If the asynchronous method pair
// appears on the client channel, the client can call
// them asynchronously to prevent blocking.
[OperationContract (AsyncPattern=true)]
IAsyncResult BeginAdd(int a, int b, AsyncCallback cb, AsyncState s);
[OperationContract]
int EndAdd(IAsyncResult r);
// This is a synchronous version of the BeginAdd/EndAdd pair.
// It appears in the client channel code by default.
[OperationContract]
int Add(int a, int b);
}
我熟悉APM,但沒有任務,但想知道你在這裏使用asyncCallback函數引用,但是當你調用AddAsync()時,你不會發送asyncCallback函數參考....爲什麼? – Mou
@Mou,'asyncCallback'將由'FromAsync'的Framework實現在內部提供,當它調用我的lambda時。 – Noseratio