Frage

We have a robust WCF client built in 2008 on .NET 3.5 (now recompiled under .NET 4.0) that talks to our own WCF service over the net.tcp binding. The robust client uses ChannelFactory<IOurServiceInterface>() to generate a service proxy, through which we currently make synchronous calls to the service. We get results back from each call; we have no one-way calls.

We are migrating to .NET 4.5 / C# 5 and would like to make the client asynchronous using async / await / TAP. How best to do this in a way that results in clean code, and good runtime performance?

(I've looked at MS documentation on this subject, but it always talks about running svcutil. We don't use svcutil; we use ChannelFactory directly. Also: MS documentation for calling operations asynchronously using a channel factory under .NET 4.5 are unchanged since .NET 3.0 days. Seems ChannelFactory hasn't embraced the new asynchrony.)

War es hilfreich?

Lösung

You can wrap existing APM (Begin*/End*) endpoints into TAP-ready Tasks using TaskFactory.FromAsync.

You may find my Async WCF Today and Tomorrow post helpful, which shows how to use TAP with the pre-VS2012 svcutil.

Andere Tipps

Did you see this ? I made an example of an awaitable [OperationContract] returning Task<TResponse>.

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