CommunicationObject.OnOpen(TimeSpan) 方法

定義

在通訊物件上插入處理 (當它轉換到開啟狀態之後),此作業必須在指定的時間間隔內完成。Inserts processing on a communication object after it transitions into the opening state which must complete within a specified interval of time.

protected:
 abstract void OnOpen(TimeSpan timeout);
protected abstract void OnOpen (TimeSpan timeout);
abstract member OnOpen : TimeSpan -> unit
Protected MustOverride Sub OnOpen (timeout As TimeSpan)

參數

timeout
TimeSpan

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

例外狀況

通訊物件並非處於 OpenedOpening 狀態,無法修改。The communication object is not in a Opened or Opening state and cannot be modified.

通訊物件處於 ClosingClosed 狀態,無法修改。The communication object is in a Closing or Closed state and cannot be modified.

通訊物件處於 Faulted 狀態,無法修改。The communication object is in a Faulted state and cannot be modified.

已超過為作業分配的預設時間間隔,該作業未完成。The default interval of time that was allotted for the operation was exceeded before the operation was completed.

備註

如果通訊物件一開始處於 Open 狀態,OnOpen(TimeSpan) 方法就會呼叫 OnOpening (在呼叫 OnOpened 之後,並且在呼叫 Created 之前)。The Open method calls OnOpen(TimeSpan) (after calling OnOpening and before calling OnOpened) if the communication object is initially in the Created state.

若要在通訊物件因為叫用非同步 OnBeginOpen(TimeSpan, AsyncCallback, Object) 作業而轉換至開啟狀態時插入處理,請使用 OnOpening 方法。To insert processing as a communication object transitions to a opening state due to the invocation of an asynchronous OnBeginOpen(TimeSpan, AsyncCallback, Object) operation, use the OnOpening method.

適用於