Async/Await WCF client in a PCL
The project I'm working on is using a WCF Service on the server side (code is in the same project). I want to extend it by writing a PCL that consumes the service and would like to implement the calls with the Async/Await pattern.
As the PCL does not support Async/Await from the start I added the BCL.Async package via Nuget to the project. But whenever I try to generate the Proxy the Task based async client can not be selected ie generated. Adding the proxy manually via ChannelFactory also does not seem to be possible in the PCL.
My current approach is generating the proxy copying the ref class and then writing the async/await pattern on my own by using the Task wrapper provided by the TPL. But is there an easier way? How would I manually write the wrapper using the async/await pattern directly without generating multiple async patterns that have the same effect?
In the end I generated the proxy and manually wrapped the generated APM model with the TaskFactory to generate an Async/Await pattern in the client within the PCL. I wrote it down in this blog post.
Edit: Updated broken link.
Have you tried using the /async parameter with the svcUtil.exe tool?
See more here ServiceModel Metadata Utility Tool (Svcutil.exe)
链接地址: http://www.djcxy.com/p/19164.html上一篇: 创建流来从Python中的字符串迭代
下一篇: 异步/等待PCL中的WCF客户端