Export (0) Print
Expand All

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)

public bool IsTerminating { get; set; }

Property Value

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

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.

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.

[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

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, 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.

Show:
© 2014 Microsoft