ICommunicationObject.Open Method

Definition

導致通訊物件從已建立狀態轉換為已開啟狀態。Causes a communication object to transition from the created state into the opened state.

Overloads

Open()

導致通訊物件從已建立狀態轉換為已開啟狀態。Causes a communication object to transition from the created state into the opened state.

Open(TimeSpan)

在指定時間間隔內,讓通訊物件從已建立狀態轉換為已開啟狀態。Causes a communication object to transition from the created state into the opened state within a specified interval of time.

Remarks

有明確逾時或無明確逾時的版本都會提供。Versions with and without an explicit timeout are provided.

Open()

導致通訊物件從已建立狀態轉換為已開啟狀態。Causes a communication object to transition from the created state into the opened state.

public:
 void Open();
public void Open ();
abstract member Open : unit -> unit
Public Sub Open ()

Exceptions

ICommunicationObject 無法開啟,而且已進入 Faulted 狀態。The ICommunicationObject was unable to be opened and has entered the Faulted state.

經過預設的開啟逾時時間之後,ICommunicationObject 就可以進入 Opened 狀態,而且也已進入 Faulted 狀態。The default open timeout elapsed before the ICommunicationObject was able to enter the Opened state and has entered the Faulted state.

Remarks

ICommunicationObject 具現化時,它會以 Created 狀態開始。When an ICommunicationObject is instantiated, it begins in the Created state. Created 狀態下,可以設定物件 (例如可以設定屬性或註冊事件),但是仍無法傳送或接收訊息。In the Created state, the object can be configured (for example, properties can be set, or events can be registered), but it is not yet usable to send or receive messages. Open 方法會使 ICommunicationObject 進入 Opening 狀態,直到開啟的作業成功、開啟的作業超時或失敗,以及物件發生錯誤,或 ICommunicationObject 已中止。The Open method causes an ICommunicationObject to enter into the Opening state where it remains until the open operation succeeds, the open operation times out or fails and the object becomes faulted, or the ICommunicationObject is aborted.

Opened 狀態中,ICommunicationObject 可供使用(例如,可以接收訊息),但無法再進行設定。In the Opened state, the ICommunicationObject is usable (for example, messages can be received), but it is no longer configurable.

也有非同步的方式可用於開啟方法,亦即藉由呼叫 BeginOpen 啟始,呼叫 EndOpen(IAsyncResult) 完成。There is also an asynchronous version of the open method that is initiated by calling BeginOpen and completed by calling EndOpen(IAsyncResult).

Open(TimeSpan)

在指定時間間隔內,讓通訊物件從已建立狀態轉換為已開啟狀態。Causes a communication object to transition from the created state into the opened state within a specified interval of time.

public:
 void Open(TimeSpan timeout);
public void Open (TimeSpan timeout);
abstract member Open : TimeSpan -> unit
Public Sub Open (timeout As TimeSpan)

Parameters

timeout
TimeSpan

TimeSpan,指定必須在逾時前多久完成傳送作業。The TimeSpan that specifies how long the send operation has to complete before timing out.

Exceptions

ICommunicationObject 無法開啟,而且已進入 Faulted 狀態。The ICommunicationObject was unable to be opened and has entered the Faulted state.

經過指定的逾時時間之後,ICommunicationObject 就可以進入 Opened 狀態,而且也已進入 Faulted 狀態。The specified timeout elapsed before the ICommunicationObject was able to enter the Opened state and has entered the Faulted state.

Remarks

ICommunicationObject 具現化時,它會以 Created 狀態開始。When an ICommunicationObject is instantiated, it begins in the Created state. Created 狀態下,可以設定物件 (例如可以設定屬性或註冊事件),但是仍無法傳送或接收訊息。In the Created state, the object can be configured (for example, properties can be set, or events can be registered), but it is not yet usable to send or receive messages. Open 方法會使 ICommunicationObject 進入 Opening 狀態,直到開啟的作業成功、開啟的作業超時或失敗,以及物件發生錯誤,或 ICommunicationObject 已中止。The Open method causes an ICommunicationObject to enter into the Opening state where it remains until the open operation succeeds, the open operation times out or fails and the object becomes faulted, or the ICommunicationObject is aborted.

Opened 狀態中,ICommunicationObject 可供使用(例如,可以接收訊息),但無法再進行設定。In the Opened state, the ICommunicationObject is usable (for example, messages can be received), but it is no longer configurable.

也有非同步的方式可用於開啟方法,亦即藉由呼叫 BeginOpen 啟始,呼叫 EndOpen(IAsyncResult) 完成。There is also an asynchronous version of the open method that is initiated by calling BeginOpen and completed by calling EndOpen(IAsyncResult).

Notes to Implementers

如果超過指定的 timeout,則作業必須擲回 TimeoutExceptionThe operation must throw a TimeoutException if the specified timeout is exceeded.

Applies to