IBindingRuntimePreferences IBindingRuntimePreferences IBindingRuntimePreferences IBindingRuntimePreferences Interface

Definición

Define el contrato opcional que un enlace puede implementar para especificar si el servicio administra de forma asincrónica o asincrónica las solicitudes entrantes.Defines the optional contract that a binding can implement to specify whether incoming requests are handled synchronously or asynchronously by the service.

public interface class IBindingRuntimePreferences
public interface IBindingRuntimePreferences
type IBindingRuntimePreferences = interface
Public Interface IBindingRuntimePreferences
Derivado

Ejemplos

El ejemplo siguiente muestra la implementación de un enlace que implementa la interfaz IBindingRuntimePreferences.The following example shows the implementation of a binding that implements the IBindingRuntimePreferences interface. Este código se toma del ejemplo de canal de fragmentación:This code is taken from the Chunking Channel sample:

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

    }
    public TcpChunkingBinding(string name, string ns)
        : base(name, ns)
    {
        Initialize();
    }
    public override BindingElementCollection CreateBindingElements()
    {
        BindingElementCollection col = new BindingElementCollection();
        col.Add(be);
        col.Add(tcpbe);
        return col;
    }

    public override string Scheme
    {
        get { return tcpbe.Scheme;  }
    }
    public int MaxBufferedChunks
    {
        get { return this.be.MaxBufferedChunks; }
        set { this.be.MaxBufferedChunks = 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; }
    }
    #endregion
}

Comentarios

Puede ser más eficaz para un enlace procesar los mensajes con los métodos sincrónicos Receive o Request en algunos casos.In some cases it may be more efficient for a binding to process messages with the synchronous Receive or Request methods. Una clase Binding puede implementar opcionalmente IBindingRuntimePreferences para indicar a los llamadores que se prefiere esto.A Binding class can optionally implement IBindingRuntimePreferences to indicate to callers that this is preferred.

Si un enlace no implementa IBindingRuntimePreferences, la capa en tiempo de ejecución del modelo de servicio Windows Communication Foundation (WCF) utiliza de forma predeterminada las versiones asincrónicas de los Receive métodos y Request .If a binding does not implement IBindingRuntimePreferences, the Windows Communication Foundation (WCF) Service Model Runtime layer defaults to using the asynchronous versions of the Receive and Request methods. Si un enlace IBindingRuntimePreferencesimplementa, la capa de tiempo de ejecución del modelo de servicio WCF comprueba el valor de ReceiveSynchronously y lo utiliza para determinar si se debe llamar a las versiones sincrónicas de estos métodos (Receive o Request) o al versiones (BeginReceive y EndReceive(IAsyncResult) o BeginRequest y .EndRequest(IAsyncResult)If a binding does implement IBindingRuntimePreferences, the WCF 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). Si IBindingRuntimePreferences es implementado por el enlace y devuelve true desde la propiedad ReceiveSynchronously, se recomienda que utilice los métodos sincrónicos Receive y Request para recibir los mensajes del canal.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. Si el enlace no implementa IBindingRuntimePreferences ni devuelve false desde la propiedad ReceiveSynchronously, se recomienda que utilice los métodos asincrónicos BeginReceive y EndReceive(IAsyncResult) o BeginRequest y EndRequest(IAsyncResult).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.

Sin tener en cuenta el valor devuelto por la propiedad ReceiveSynchronously, todos los enlaces deben proporcionar implementaciones válidas de la versión sincrónica y de la asincrónica de los métodos Receive para los tipos de canal concretos implementados.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. Para obtener más información sobre la implementación de canales personalizados, consulte desarrollo de canales.For more information about implementing custom channels, see Developing Channels.

Propiedades

ReceiveSynchronously ReceiveSynchronously ReceiveSynchronously ReceiveSynchronously

Obtiene un valor que indica si se pueden administrar más eficazmente las solicitudes entrantes de forma sincrónica o asincrónica.Gets a value that indicates whether incoming requests can be handled more efficiently synchronously or asynchronously.

Se aplica a