.NET Framework Class Library
OperationContractAttribute..::.IsTerminating Property

Gets or sets a value that indicates whether the service operation causes the server to close the session after the reply message, if any, is sent.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Syntax

Visual Basic (Declaration)
Public Property IsTerminating As Boolean
Visual Basic (Usage)
Dim instance As OperationContractAttribute
Dim value As Boolean

value = instance.IsTerminating

instance.IsTerminating = value
C#
public bool IsTerminating { get; set; }
Visual C++
public:
property bool IsTerminating {
    bool get ();
    void set (bool value);
}
JScript
public function get IsTerminating () : boolean
public function set IsTerminating (value : boolean)

Property Value

Type: System..::.Boolean
true if the operation causes the server to close the session, otherwise, false. The default is false.
Remarks

Use the IsTerminating property to indicate that calling a service operation terminates the communication session.

In a client application, a value of IsTerminating set to true instructs WCF to close the channel after the reply arrives.

In a service, a timer is set and the channel aborts if the client does not close the channel within that period.

For more information about using this property with sessions, see Using Sessions.

NoteNote:

If a caller is listening for the OperationContext..::.OperationCompleted event for an OperationContractAttribute..::.IsTerminating operation, it is possible to block when the response is received. The proper way to handle this is to schedule work on another thread when OperationCompleted is raised and then immediately return from that event handler.

Examples

The following example is a service that implements a service contract that specifies three operations. The service requires a stateful connection. If a caller's first call is to any operation other than MethodOne, the channel is refused and an exception is thrown. When a caller initiates a session by calling MethodOne, that caller can terminate the communication session at any time by calling MethodThree. MethodTwo can be called any number of times during a session.

C#
[ServiceContractAttribute(SessionMode=SessionMode.Required)]
public class InitializeAndTerminateService
{
  [OperationContract(
    IsOneWay=true,
    IsInitiating=true,
    IsTerminating=false
  )]
  public void MethodOne()
  {
    return;
  }

  [OperationContract(
    IsInitiating=false,
    IsTerminating=false
  )]
  public int MethodTwo(int x, out int y)
  {
    y = 34;
    return 0;
  }

  [OperationContract(
    IsOneWay=true,
    IsInitiating=false
    IsTerminating=true
  )]
  public void MethodThree()
  {
    return;
  }
}
.NET Framework Security

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Tags :


Page view tracker