Why would you do that? WCF can accept multiple Requests over one Client with ConcurrencyMode.Multiple
. So it wouldn't make much sense to initialize two Clients..
WCF ServiceContract has three important Attributes for this behaviour,
InstanceContextMode
- PerSession (Creates per Session an Instance of the Service)
- Single (Creates Single Instance for every Client)
- PerCall (Creates per Call an Instance of the Service)
ConcurrencyMode
- Multiple (Client can make multiple calls at the same time -> Multithreaded)
- Single (Client can make one call and other have to wait until the other call finished)
- Reentrant (Client can make multiple calls at the same time, i don't know exactly but i think it was like if one call uses another wcf service, another call can be processed until the other wcf service call is completed, so it releases the lock between time of wcf service call is made and response)
SessionMode
- Allowed (Client can use a Session but don't have to)
- NotAllowed (Client can't use a Session)
- Required (Client have to use Session)
Most time I use InstanceContextMode.PerSession
(Because Client 1 doesnt have access to the Variables in the Service of Client 2), ConcurrencyMode.Multiple
and SessionMode.Required
.
You can also specify how many Instances can be initialized, how many Concurrent Calls can be made and how many Session can be used.