none
How Task Based Async pattern WCF Client Proxy class be emit? RRS feed

  • Question

  • Hello everyone.

    There is something puzzled to me about Task Based Async pattern for WCF client proxy.

    before .NET 4.5 ,for sample .net 4.0. i kown ChannelFactory Create Channel by emit async method  according to seting System.ServiceModel.OperationContractAttribute.AsyncPattern as true.

    but in .NET 4.5 , there is something changed to using Task Based Async pattern, so there is something puzzled me,

    what the channel factory according to emit the Async Method? because of the return vaule is Task type?

    like code below. the async and sync method have the same OperationContractAttribute declaration,so the channel factory how to distinguish async or sync?

            [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetData", ReplyAction="http://tempuri.org/IService1/GetDataResponse")]
            string GetData(int value);
            
            [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IService1/GetData", ReplyAction="http://tempuri.org/IService1/GetDataResponse")]
            System.Threading.Tasks.Task<string> GetDataAsync(int value);

    thanks advance...


    DON'T TRY SO HARD,THE BEST THINGS COME WHEN YOU LEAST EXPECT THEM TO.


    Monday, August 4, 2014 2:26 AM

Answers

  • Hi,

    In Visual Studio 2012 and WCF 4.5, there is a new option available to generate task-based operations so that the code from the client-side can be less complex. Task-based asynchronous programming is now simplified and streamlined in .NET 4.5 by the keywords "await" and "async".

    Then for the question about using Task Async Pattern with WCF's ChannelFactory, please try to refer to this similar thread:
    http://stackoverflow.com/questions/13443022/how-to-apply-task-async-pattern-and-wcfs-channelfactorytchannel .


    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, August 5, 2014 6:09 AM
    Moderator