ReleaseInstanceMode Enumeration
.NET Framework 3.0
Specifies when the system recycles the service object in the operation invocation process.
Namespace: System.ServiceModel
Assembly: System.ServiceModel (in system.servicemodel.dll)
Assembly: System.ServiceModel (in system.servicemodel.dll)
| Member name | Description | |
|---|---|---|
| AfterCall | Recycles the object subsequent to the completion of the operation. | |
| BeforeAndAfterCall | Recycles the object prior to calling the operation and subsequent to the completion of the operation. | |
| BeforeCall | Recycles the object prior to calling the operation. | |
| None | Recycles the object according to the InstanceContextMode value. |
Use the ReleaseInstanceMode with the ReleaseInstanceMode property to inform Windows Communication Foundation (WCF) that the current service object must be recycled at a particular point in the invocation process. The default behavior is to recycle a service object according to the InstanceContextMode value.
The following example code shows the use of ReleaseInstanceMode to recycle service objects both before and after a call.
class SampleService : ISampleService { private Guid id; private string session; public SampleService() { id = Guid.NewGuid(); session = OperationContext.Current.SessionId; Console.WriteLine("Object {0} has been created.", id); Console.WriteLine("For session {0}", session); } [OperationBehavior( ReleaseInstanceMode=ReleaseInstanceMode.BeforeAndAfterCall )] public string SampleMethod(string msg) { Console.WriteLine("The caller said: \"{0}\"", msg); Console.WriteLine("For session {0}", OperationContext.Current.SessionId); return "The service greets you: " + msg; } ~SampleService() { Console.WriteLine("Object {0} has been destroyed.", id); Console.WriteLine("For session {0}", session); } }
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: