ICommunicationObject.BeginClose 方法

定義

開始非同步作業以關閉通訊物件。Begins an asynchronous operation to close a communication object.

多載

BeginClose(AsyncCallback, Object)

開始非同步作業以關閉通訊物件。Begins an asynchronous operation to close a communication object.

BeginClose(TimeSpan, AsyncCallback, Object)

開始非同步作業,關閉有已指定逾時的通訊物件。Begins an asynchronous operation to close a communication object with a specified timeout.

備註

這個方法會讓 ICommunicationObjectOpened 狀態正常轉換為 Closed 狀態。This method causes an ICommunicationObject to gracefully transition from the Opened state to the Closed state.

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

BeginClose(AsyncCallback, Object)

開始非同步作業以關閉通訊物件。Begins an asynchronous operation to close a communication object.

public:
 IAsyncResult ^ BeginClose(AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginClose (AsyncCallback callback, object state);
abstract member BeginClose : AsyncCallback * obj -> IAsyncResult
Public Function BeginClose (callback As AsyncCallback, state As Object) As IAsyncResult

參數

callback
AsyncCallback

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

state
Object

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

傳回

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

例外狀況

已針對處於 BeginClose(AsyncCallback, Object) 狀態中的物件呼叫 FaultedBeginClose(AsyncCallback, Object) was called on an object in the Faulted state.

經過預設的逾時時間之後,就可以正常關閉 ICommunicationObjectThe default timeout elapsed before the ICommunicationObject was able to close gracefully.

備註

這個方法會讓 ICommunicationObjectOpened 狀態以外的任何狀態正常轉換為 Closed 狀態。This method causes an ICommunicationObject to gracefully transition from any state, other than the Opened state to the Closed state. BeginClose 方法可讓任何未完成的工作在傳回前完成The BeginClose method allows any unfinished work to be completed before returning. (例如,完成傳送任何經過緩衝處理的訊息)。For example, finish sending any buffered messages).

BeginClose(TimeSpan, AsyncCallback, Object)

開始非同步作業,關閉有已指定逾時的通訊物件。Begins an asynchronous operation to close a communication object with a specified timeout.

public:
 IAsyncResult ^ BeginClose(TimeSpan timeout, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginClose (TimeSpan timeout, AsyncCallback callback, object state);
abstract member BeginClose : TimeSpan * AsyncCallback * obj -> IAsyncResult
Public Function BeginClose (timeout As TimeSpan, callback As AsyncCallback, state As Object) As IAsyncResult

參數

timeout
TimeSpan

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

callback
AsyncCallback

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

state
Object

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

傳回

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

例外狀況

經過指定的逾時時間之後,就可以正常關閉 ICommunicationObjectThe specified timeout elapsed before the ICommunicationObject was able to close gracefully.

備註

這個方法 ICommunicationObject 會在指定的時間間隔內,從 Opened 狀態以外的任何狀態,正常地轉換為 Closed 狀態。This method causes an ICommunicationObject to gracefully transition from any state, other than the Opened state to the Closed state with in a specified interval of time. BeginClose 方法可讓任何未完成的工作在傳回前完成The BeginClose method allows any unfinished work to be completed before returning. (例如,完成傳送任何經過緩衝處理的訊息)。For example, finish sending any buffered messages).

適用於