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 everything executed sequentially as I am invoking operations synchronously. I changed the concurrency mode to multiple, but still the operations happened synchronously. Then I generated asynchronous methods for my operations and uses the begin/end patterns so which I guess "freed" the channel and let the operations happen in parallel/asynchronously increasing the throughput of my applications.

Then I used ChannelFactory to create a channel and performed the operations as the client and server can share the contracts (same project). But IClientChannel provides only BeginOpen/EndOpen/BeignClose/EndClose. It doesn't have the ClientBase's BeginOperation/EndOperation methods. So basically I cannot execute an operation asynchronously on the channel to free up so that I can use the channel to perform other operations.

The I simply created channels for every operation and it solved the problem

So my question is:

  1. Which is better (ClientBase vs. ChannelFactory) w.r.t to my scenario especially I want to perform multiple operations on the service object simultaneously with multiple threads

  2. Is it advisable to create a channel for each and every operation?

  3. In fact, I thought we can have only one channel between two endpoints (client/service). But I can create as many channels as I want. For ex: I was able to create Int16.MaxValue of channels. So not sure what the limit and recommendations on this.

    Service[] channels = new IService[Int16.MaxValue];
    
    for(int i = 0; i<Int16.MaxValue; i++)
    {
       channels[i] = factory.CreateChannel();
    }
    

So basically can you please let me know about the basics of channels and recomme

Edit
Report