System.ServiceModel 4.0.0.0

Implement the interface to provide the appropriate 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 to decide which session or call from a client is associated with which object. For an example that demonstrates the sharing of instance contexts, see InstanceContextSharing.

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

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

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

- Method
  4.0.0.0
  System.ServiceModel.InstanceContext `` ``

  The method is called when a message is received. Return the object that you want to process the message, or null. In the case of null, indigo2 creates a new object for the message and then calls the method.

  If you return null, the new object goes through the throttling system and increments the count of .

  Called when a new message is received.

  The object that is used to process the message; return null to instruct indigo2 to create a new object.

  The incoming message. The channel that received the message.
- Method
  4.0.0.0
  System.Void `` `` ``

  is called when returns null and a new object is created. This method is called to notify you that a new has been created.

  Called when null is returned from the method.

  The new object. The incoming message. The channel that received the message.
- Method
  4.0.0.0
  System.Boolean ``

  is called when indigo2 is about to close and recycle an idle object so that you can inform the runtime whether to continue doing so.

  For an example that demonstrates the sharing of instance contexts, see InstanceContextSharing.

  Called when all activities have completed to enable implementers to prevent the from being recycled.

  true if indigo1 is to close and recycle the object and adjust the value of ; otherwise, false.

  The object that is considered idle.
- Method
  4.0.0.0
  System.Void `` ``

  The method is called when the method returns false to enable you to provide indigo2 with a object that you use to inform the runtime that the has finished its work. When the object notifies the runtime that the has finished its work, indigo2 calls once again. This cycle continues until returns true and the context is closed and recycled.

  Called when the method returns false to enable implementers to provide a callback to notify indigo2 when the object is finished.

  The object that notifies indigo2 when the object is to be closed and recycled. The current .