if wcf service is design the below way then please guide me how call Add()
function Asynchronously
from client side. thanks
[Servic
There is no such thing as an async wire communication pattern, and WFC is no exception. Going async across the wire requires fundamental changes in your service and your contract. Specifically your contract has to be a bidirectional contract and the 'end' must be pushed from the service to the client, along with the result. In other words, across the wire the 'async' becomes a callback.
I think the best way is to convert the APM pattern into the Task pattern, using Task.Factory.FromAsync:
public static class WcfExt
{
public static Task<int> AddAsync(this IAddTwoNumbers service, int a, int b)
{
return Task.Factory.FromAsync(
(asyncCallback, asyncState) =>
service.BeginAdd(a, b, asyncCallback, asyncState),
(asyncResult) =>
service.EndAdd(asyncResult), null);
}
}
Usage:
IAddTwoNumbers service = CreateWcfClientProxy();
int result = await service.AddAsync(a, b);