The instance Context pattern (InstanceContextMode) can be simply understood as the association between the service instance of the server and the service agent of the client. WCF has monotonic (Per-call), session (Per-session), and Singleton (single)
Monotonous (Per-call)
[ServiceBehavior (InstanceContextMode = instancecontextmode.percall)] public class Testservice:itest
Session (Per-session)
[ServiceBehavior (InstanceContextMode = instancecontextmode.persession)] public class Testservice:itest
Singleton (single)
[ServiceBehavior (InstanceContextMode = instancecontextmode.single)] public class Testservice:itest
Second, concurrency
Defining concurrency Patterns with the ServiceBehaviorAttribute attribute
WCF defines three typical concurrency patterns for single, reentrant, and multiple for three typical concurrent processing policies.
Single: An instance context can only be used at a time to handle a singleton request, or multiple concurrent requests for only one instance context will be processed in a serial manner.
[ServiceBehavior (InstanceContextMode = instancecontextmode.single, ConcurrencyMode = ConcurrencyMode.Single)] Public class Testservice:itest
Reentrant: An instance context object can only be used for processing a single request at some point. If the service operation involves a callback (Callback) to the client during execution, the instance context can be used for processing other service invocation requests during the callback process. If the service instance context is not processed for another request after the callback operation executes, the callback operation can be processed.
[ServiceBehavior (InstanceContextMode = instancecontextmode.single, ConcurrencyMode = ConcurrencyMode.Reentrant )] Public class Testservice:itest
Multiple: An instance context can be used to process multiple service requests at the same time.
[ServiceBehavior (InstanceContextMode = instancecontextmode.single, concurrencymode = ConcurrencyMode.Multiple) ] Public class Testservice:itest
WCF instance context and concurrency