I am new to WCF. Initially I created a WCF service and used the generated client proxy to consume the service from client. So whenever I performed some operations on service
There's a difference using async between ClientBase
and ChannelFactory<T>
. Basically ClientBase
uses the event-driven asynchronous model.
I used ChannelFactory<T>
extensively in an application I developed at work, mainly because the contracts were available in a common library for the application and I don't like using the Add Service Reference. I cache each unique instance of the ChannelFactory upon creation, and then when I need to call an operation I'll open a communication channel from that instance, make my call, and close the communication channel.
Most of the startup cost for WCF is in creation of the client, and this way you only pay it once for the life of the application - creating communication channels is trivial.
For more info on the async for ClientBase
and ChannelFactory<T>
, see:
How to: Call WCF Service Operations Asynchronously
How to: Call Operations Asynchronously Using a Channel Factory