Why would you do this? WCF can accept multiple requests per client using ConcurrencyMode.Multiple . Therefore, it would not make sense to initialize two Clients.
WCF ServiceContract has three important attributes for this behavior:
InstanceContextMode
- PerSession (creates a service instance for each session)
- Single (creates a single instance for each client)
- PerCall (created to invoke a service instance)
ConcurrencyMode
- Multiple (Client can make several calls simultaneously β Multithreading)
- Single (the client can make one call, and the other must wait for the completion of another call)
- Reentrant (the client can make several calls at the same time, I donβt know for sure, but I think that if one call uses another wcf service, the other call can be processed until the other wcf service call is completed, so it releases the lock between wcf service call time and response)
Sessionmode
- Allowed (client can use session, but not required)
- NotAllowed (client cannot use session)
- Required (client must use session)
In most cases, I use InstanceContextMode.PerSession (since client 1 does not have access to variables in client service 2), ConcurrencyMode.Multiple and SessionMode.Required .
You can also specify how many instances can be initialized, how many simultaneous calls, and how many sessions you can use.
RaphaelH
source share