CommunicationObject.OnBeginClose(TimeSpan, AsyncCallback, Object) 方法

定義

在通訊物件因為叫用非同步關閉作業而轉換到關閉狀態後,插入處理。Inserts processing after a communication object transitions to the closing state due to the invocation of an asynchronous close operation.

protected:
 abstract IAsyncResult ^ OnBeginClose(TimeSpan timeout, AsyncCallback ^ callback, System::Object ^ state);
protected abstract IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state);
abstract member OnBeginClose : TimeSpan * AsyncCallback * obj -> IAsyncResult
Protected MustOverride Function OnBeginClose (timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult

參數

timeout
TimeSpan

指定必須在逾時前完成關閉作業之寬限時間的 TimeSpanThe TimeSpan that specifies how long the on close operation has to complete before timing out.

callback
AsyncCallback

AsyncCallback 委派,這個委派會接收非同步關閉作業完成的通知。The AsyncCallback delegate that receives notification of the completion of the asynchronous on close operation.

state
Object

應用程式所指定的物件,其中包含與非同步關閉作業相關的狀態資訊。An object, specified by the application, that contains state information associated with the asynchronous on close operation.

傳回

參考非同步關閉作業的 IAsyncResultThe IAsyncResult that references the asynchronous on close operation.

例外狀況

通訊物件並非處於 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.

備註

如果通訊物件一開始處於 BeginClose 狀態,OnBeginClose 方法就會呼叫 OpenedThe BeginClose method calls OnBeginClose if the communication object is initially in the Opened state.

若要在通訊物件因為叫用同步 Close 作業而轉換至關閉狀態後插入處理,請使用 OnClose(TimeSpan) 方法。To insert processing after a communication object transitions to a closing state due to the invocation of a synchronous Close operation, use the OnClose(TimeSpan) method.

適用於