Frage

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 i.e. 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?

War es hilfreich?

Lösung

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.

Andere Tipps

Have you tried using the /async parameter with the svcUtil.exe tool?

See more here ServiceModel Metadata Utility Tool (Svcutil.exe)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top