1 out of 1 rated this helpful - Rate this topic

IInstanceContextProvider Interface

Implement to participate in the creation or choosing of a System.ServiceModel.InstanceContext object, especially to enable shared sessions.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public interface IInstanceContextProvider

The IInstanceContextProvider type exposes the following members.

  Name Description
Public method GetExistingInstanceContext Called when a new message is received.
Public method InitializeInstanceContext Called when null is returned from the GetExistingInstanceContext method.
Public method IsIdle Called when all InstanceContext activities have completed to enable implementers to prevent the InstanceContext from being recycled.
Public method NotifyIdle Called when the IsIdle method returns false to enable implementers to provide a callback to notify when the InstanceContext object is finished.
Top

Implement the IInstanceContextProvider interface to provide the appropriate System.ServiceModel.InstanceContext object to the system. Typically, this interface is implemented to support shared sessions, enable service instance pooling, control lifetimes of service instances, or to group contexts among clients.

For example, to implement sharing, insert a custom IInstanceContextProvider to decide which session or call from a client is associated with which InstanceContext object. For an example that demonstrates the sharing of instance contexts, see InstanceContextSharing.

Note Note

When an IInstanceContextProvider is inserted into , the normal property that controls the creation of InstanceContext objects (the ServiceBehaviorAttribute.InstanceContextMode property) is no longer checked and has no effect.

A more generic mechanism by which you can initialize InstanceContext objects when created (for example, to attach custom extensions to each InstanceContext) is the System.ServiceModel.Dispatcher.IInstanceContextInitializer.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Missing word in the remarks
"When an IInstanceContextProvider is inserted into MISSING WORD HERE, the normal property that controls the creation of InstanceContext objects (the ServiceBehaviorAttribute.InstanceContextMode property) is no longer checked and has no effect."

It should say: "When an IInstanceContextProvider is inserted into the DispatchRuntime, the normal property..."