c# - Calling async WCF without service reference using ChannelFactory -


i'm using .net 3.5 this related question using tpl async library, since i'm in 3.5 need approach.

i used call wcf asynchronously adding service reference , creating async operations using visual studio 2010.

now i've created dynamic proxy using createchannel<t> of channelfactory class , need call method in async way. how create wcf proxy:

    public myinterface proxy { get; set; }      basichttpbinding binding = new basichttpbinding();     endpointaddress ep = new endpointaddress("http://localhost/myendpoint");     proxy = channelfactory<myinterface>.createchannel(binding, ep);       // call method     proxy.mymethod();      [servicecontract]     public interface myinterface     {       [operationcontract]       void mymethod();     } 

i don't need service response.

i'm not sure if understood correctly, if want make proxy.mymethod run async means of .net 3.5, can use standart begininvoke of delegate class, this:

 //make delegate proxy.mymethod  private delegate void mydelegate(); 

then in code, call method async:

basichttpbinding binding = new basichttpbinding(); endpointaddress ep = new endpointaddress("http://localhost/myendpoint"); proxy = channelfactory<myinterface>.createchannel(binding, ep);  var delinstance = new mydelegate(proxy.mymethod); var result = delinstance.begininvoke(); 

if need check results, use result variable this


Comments