ReleaseInstanceMode ReleaseInstanceMode ReleaseInstanceMode ReleaseInstanceMode Enum

Définition

Spécifie quand le système recycle l'objet de service dans le processus d'appel d'opération.Specifies when the system recycles the service object in the operation invocation process.

public enum class ReleaseInstanceMode
public enum ReleaseInstanceMode
type ReleaseInstanceMode = 
Public Enum ReleaseInstanceMode
Héritage
ReleaseInstanceModeReleaseInstanceModeReleaseInstanceModeReleaseInstanceMode

Champs

AfterCall AfterCall AfterCall AfterCall 2

Recycle l'objet après la fin de l'opération.Recycles the object subsequent to the completion of the operation.

BeforeAndAfterCall BeforeAndAfterCall BeforeAndAfterCall BeforeAndAfterCall 3

Recycle l'objet avant d'appeler l'opération et après la fin de l'opération.Recycles the object prior to calling the operation and subsequent to the completion of the operation.

BeforeCall BeforeCall BeforeCall BeforeCall 1

Recycle l'objet avant d'appeler l'opération.Recycles the object prior to calling the operation.

None None None None 0

Recycle l'objet d'après la valeur InstanceContextMode.Recycles the object according to the InstanceContextMode value.

Exemples

Le code d'exemple suivant illustre l'utilisation de ReleaseInstanceMode pour recycler des objets de service avant et après un appel.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);
  }
}
 Friend Class SampleService
  Implements ISampleService
Private id As Guid
Private session As String

Public Sub New()
  id = Guid.NewGuid()
  session = OperationContext.Current.SessionId
  Console.WriteLine("Object {0} has been created.", id)
  Console.WriteLine("For session {0}", session)
End Sub
<OperationBehavior(ReleaseInstanceMode:=ReleaseInstanceMode.BeforeAndAfterCall)> _
Public Function SampleMethod(ByVal msg As String) As String Implements ISampleService.SampleMethod
  Console.WriteLine("The caller said: ""{0}""", msg)
  Console.WriteLine("For session {0}", OperationContext.Current.SessionId)
  Return "The service greets you: " & msg
End Function

Protected Overrides Sub Finalize()
  Console.WriteLine("Object {0} has been destroyed.", id)
  Console.WriteLine("For session {0}", session)
End Sub
 End Class

Remarques

Utilisez le ReleaseInstanceMode avec le ReleaseInstanceMode propriété afin d’informer Windows Communication Foundation (WCF) que l’objet de service actuel doit être recyclé à un moment précis dans le processus d’appel.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. Par défaut, l'objet de service est recyclé en fonction de la valeur InstanceContextMode.The default behavior is to recycle a service object according to the InstanceContextMode value.

S’applique à