共用方式為


ChannelDispatcher.ReceiveSynchronously 屬性

定義

取得或設定值,這個值會指定發送器是否使用同步呼叫來讀取通道中的訊息。

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

例外狀況

通訊物件處於 OpeningOpened 狀態中。

通訊物件處於 ClosingClosed 狀態中。

通訊物件處於 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,就會覆寫 falseReceiveSynchronously 預設值。

只有在 ChannelDispatcher 的執行個體處於 Created 狀態時才可以設定這個屬性,因為這是唯一同時處於可變動且尚未處置的狀態。

適用於