This topic has not yet been rated - Rate this topic

DispatchRuntime.InstanceProvider Property

Gets or sets an IInstanceProvider object that you can use to control the creation and destruction of service objects.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
public IInstanceProvider InstanceProvider { get; set; }

Property Value

Type: System.ServiceModel.Dispatcher.IInstanceProvider
An IInstanceProvider object that controls the creation and destruction of service objects associated with an InstanceContext object.

Implement the IInstanceProvider interface and assign the implementation to the InstanceProvider property to control instances of the service type using a constructor other than the default constructor, for example, to implement a custom instancing mode such as instance pooling.

Typically the GetInstance method is invoked once, when the InstanceContext object is first created. The ReleaseInstance method is also invoked once, when the InstanceContext object is closed.

A service can also be configured to release an instance before the InstanceContext object is closed. This can be configured by using the ReleaseInstanceMode property or by calling the ReleaseServiceInstance method. If this is done, the InstanceContext object calls the ReleaseInstance method. If a new message arrives after the instance has been released, a new instance is created using the GetInstance method.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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)
© 2013 Microsoft. All rights reserved.