Creating Asynchronous WCF Clients Without Using Service Links

I currently do not use service links, because I feel that the code that it autogenerates is more weight than I need. Instead, I generate a proxy class by doing:

public class MyClient : ClientBase<IMyService>, IMyService

This is great for me, no proxy classes are generated, so I reuse the same data types. But this allows me to create synchronous client methods.

What do you need to create asynchronous versions? I took a look at the auto-generated code that the Service Reference will add, and it looks like soo muchplate. A ton of start / end / onbegin / oncomplete related arg datatypes events, etc. Etc.

Is there an easier way with fewer forests needed to create asynchronous client methods? My ultimate goal is to use the new async / wait C # 5 keywords for webservice clients

+3
source share
3 answers

You can always create a contract IMyAsyncServicethat exactly matches IMyService, but uses the Begin / End asynchronization pattern (and has [ServiceContract(Name="IMyService")]to keep the same name). It will be the same wired contract, and work with ClientBase, but now you have asynchronous methods that you can use with await.

+2
source

I think adding this [OperationContract (IsOneWay = true)]

.

0

CTP for async / await is just a preview of support for these features. They plan to fully integrate them into WCF.

http://blogs.msdn.com/b/endpoint/archive/2010/11/13/simplified-asynchronous-programming-model-in-wcf-with-async-await.aspx

0
source

Source: https://habr.com/ru/post/1773977/


All Articles