Given this interface
[ServiceContract]
public interface IProductService
{
[OperationContract]
Product Get(int id);
}
I would like to manually (that is, without using scvutil or Add Service Reference in VS) create a client-side proxy.
I do it in the following way
public class ProductService: IProductService
{
readonly ChannelFactory<IProductService> factory;
public ProductService()
{
factory = new ChannelFactory<IProductService>("*");
}
public Product Get(int id)
{
var channel = factory.CreateChannel();
return channel.Get(id);
}
}
My problem is that I also want async/await version of this method, only on client-side, server side is still synchronous.
I want this to be a generic solution because I have many methods and services of this sort.
Task.Run()
orFromResult()
?