ChannelDispatcher.ReceiveSynchronously 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指定调度程序是否使用同步调用从通道读取消息。
public:
property bool ReceiveSynchronously { bool get(); void set(bool value); };
public bool ReceiveSynchronously { get; set; }
member this.ReceiveSynchronously : bool with get, set
Public Property ReceiveSynchronously As Boolean
属性值
如果调度程序使用同步方法从通道读取消息,则为 true
,否则为 false
。 默认值为 false
。
例外
通信对象处于 Faulted 状态。
示例
Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);
serviceHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorServiceObject");
serviceHost.Open();
IChannelListener icl = serviceHost.ChannelDispatchers[0].Listener;
ChannelDispatcher dispatcher = new ChannelDispatcher(icl);
bool receiveSynchronously = dispatcher.ReceiveSynchronously;
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)
serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")
serviceHost.Open()
Dim icl As IChannelListener = serviceHost.ChannelDispatchers(0).Listener
Dim dispatcher As New ChannelDispatcher(icl)
Dim receiveSynchronously As Boolean = dispatcher.ReceiveSynchronously
注解
如果绑定实现 IBindingRuntimePreferences,则 Windows Communication Foundation (WCF) 将 属性的值 ReceiveSynchronously 分配给此属性。 因此,如果此值为 true
,则重写 false
的 ReceiveSynchronously 默认值。
只有当 ChannelDispatcher 的实例处于 Created 状态时才可以设置此属性,因为该状态是唯一一个可变且不被释放的状态。