CommunicationObject.BeginOpen 方法

定義

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

多載

BeginOpen(AsyncCallback, Object)

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

BeginOpen(TimeSpan, AsyncCallback, Object)

開始非同步作業,開啟有已指定時間間隔的通訊物件。Begins an asynchronous operation to open a communication object within a specified interval of time.

BeginOpen(AsyncCallback, Object)

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

public:
 virtual IAsyncResult ^ BeginOpen(AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginOpen (AsyncCallback callback, object state);
abstract member BeginOpen : AsyncCallback * obj -> IAsyncResult
override this.BeginOpen : AsyncCallback * obj -> IAsyncResult
Public Function BeginOpen (callback As AsyncCallback, state As Object) As IAsyncResult

參數

callback
AsyncCallback

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

state
Object

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

傳回

IAsyncResult

參考非同步開啟作業的 IAsyncResultThe IAsyncResult that references the asynchronous open 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.

備註

如果通訊物件一開始處於 OnBeginOpen(TimeSpan, AsyncCallback, Object) 狀態,OnOpening 方法就會呼叫 OnBeginOpen(TimeSpan, AsyncCallback, Object)CreatedThe OnBeginOpen(TimeSpan, AsyncCallback, Object) method calls OnOpening and OnBeginOpen(TimeSpan, AsyncCallback, Object) if the communication object is initially in the Created state.

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

適用於

BeginOpen(TimeSpan, AsyncCallback, Object)

開始非同步作業,開啟有已指定時間間隔的通訊物件。Begins an asynchronous operation to open a communication object within a specified interval of time.

public:
 virtual IAsyncResult ^ BeginOpen(TimeSpan timeout, AsyncCallback ^ callback, System::Object ^ state);
public IAsyncResult BeginOpen (TimeSpan timeout, AsyncCallback callback, object state);
abstract member BeginOpen : TimeSpan * AsyncCallback * obj -> IAsyncResult
override this.BeginOpen : TimeSpan * AsyncCallback * obj -> IAsyncResult
Public Function BeginOpen (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 open operation.

state
Object

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

傳回

IAsyncResult

參考非同步開啟作業的 IAsyncResultThe IAsyncResult that references the asynchronous open 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.

備註

如果通訊物件一開始處於 BeginOpen(TimeSpan, AsyncCallback, Object) 狀態,OnOpening 方法就會呼叫 OnBeginOpen(TimeSpan, AsyncCallback, Object)CreatedThe BeginOpen(TimeSpan, AsyncCallback, Object) method calls OnOpening and OnBeginOpen(TimeSpan, AsyncCallback, Object) if the communication object is initially in the Created state.

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

適用於