This documentation is archived and is not being maintained.

IBindingRuntimePreferences Interface

Defines the optional contract that a binding can implement to specify whether incoming requests are handled synchronously or asynchronously by the service.

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

public interface IBindingRuntimePreferences

The IBindingRuntimePreferences type exposes the following members.

Public propertyReceiveSynchronouslyGets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously.

In some cases it may be more efficient for a binding to process messages with the synchronous Receive or Request methods. A Binding class can optionally implement IBindingRuntimePreferences to indicate to callers that this is preferred.

If a binding does not implement IBindingRuntimePreferences, the Service Model Runtime layer defaults to using the asynchronous versions of the Receive and Request methods. If a binding does implement IBindingRuntimePreferences, the Service Model Runtime layer checks the value of ReceiveSynchronously and uses that to determine whether to call the synchronous versions of the these methods (Receive or Request) or the asynchronous versions (BeginReceive and EndReceive(IAsyncResult) or BeginRequest and EndRequest(IAsyncResult). If IBindingRuntimePreferences is implemented by the binding and returns true from the ReceiveSynchronously property, it is recommended that you use the synchronous Receive and Request methods to receive messages from the channel. If the binding does not implement IBindingRuntimePreferences or returns false from the ReceiveSynchronously property, it is recommended that you use the asynchronous BeginReceive and EndReceive(IAsyncResult) or BeginRequest and EndRequest(IAsyncResult) methods.

Regardless of the value returned by the ReceiveSynchronously property, all bindings must still provide valid implementations of both the synchronous and asynchronous versions of the Receive methods for the specific channel types implemented. For more information about implementing custom channels, see Developing Channels.

The following example shows the implementation of a binding that implements the IBindingRuntimePreferences interface. This code is taken from the Chunking Channel sample:

public class TcpChunkingBinding : Binding, IBindingRuntimePreferences
    TcpTransportBindingElement tcpbe;
    ChunkingBindingElement be;
    public TcpChunkingBinding()
        : base()

    public TcpChunkingBinding(string name, string ns)
        : base(name, ns)
    public override BindingElementCollection CreateBindingElements()
        BindingElementCollection col = new BindingElementCollection();
        return col;

    public override string Scheme
        get { return tcpbe.Scheme;  }
    public int MaxBufferedChunks
        get { return; }
        set { = value; }

    void Initialize()
         be = new ChunkingBindingElement();
         tcpbe = new TcpTransportBindingElement();
        tcpbe.TransferMode=TransferMode.Buffered; //no transport streaming
        tcpbe.MaxReceivedMessageSize = ChunkingUtils.ChunkSize + 100 * 1024; //add 100KB for headers
         this.SendTimeout = new TimeSpan(0, 5, 0);
         this.ReceiveTimeout = this.SendTimeout;


    #region IBindingRuntimePreferences Members
    public bool ReceiveSynchronously
        get { return true; }

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.