Control.EndInvoke(IAsyncResult) 方法

定義

擷取由傳遞的 IAsyncResult 表示的非同步作業的傳回值。Retrieves the return value of the asynchronous operation represented by the IAsyncResult passed.

public:
 virtual System::Object ^ EndInvoke(IAsyncResult ^ asyncResult);
public object EndInvoke (IAsyncResult asyncResult);
abstract member EndInvoke : IAsyncResult -> obj
override this.EndInvoke : IAsyncResult -> obj
Public Function EndInvoke (asyncResult As IAsyncResult) As Object

參數

asyncResult
IAsyncResult

表示特定叫用非同步作業的 IAsyncResult,在呼叫 BeginInvoke(Delegate) 時傳回。The IAsyncResult that represents a specific invoke asynchronous operation, returned when calling BeginInvoke(Delegate).

傳回

Object

非同步作業產生的 ObjectThe Object generated by the asynchronous operation.

實作

例外狀況

asyncResult 參數值為 nullThe asyncResult parameter value is null.

asyncResult 物件不是由同一控制項中 BeginInvoke(Delegate) 方法的前一個呼叫建立。The asyncResult object was not created by a preceding call of the BeginInvoke(Delegate) method from the same control.

備註

如果尚未完成非同步作業,此函式將會封鎖,直到有可用的結果為止。If the asynchronous operation has not been completed, this function will block until the result is available.

注意

除了 InvokeRequired 屬性之外,控制項上有四個安全線程的方法: InvokeBeginInvokeEndInvoke 和( CreateGraphics 如果已經建立控制項的控制碼)。In addition to the InvokeRequired property, there are four methods on a control that are thread safe: Invoke, BeginInvoke, EndInvoke, and CreateGraphics if the handle for the control has already been created. CreateGraphics 背景執行緒上建立控制項控制碼之前呼叫,可能會導致不合法的跨執行緒呼叫。Calling CreateGraphics before the control's handle has been created on a background thread can cause illegal cross thread calls. 針對其他所有方法呼叫,您應該使用其中一個叫用方法,將呼叫封送處理至控制項的執行緒。For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread.

適用於

另請參閱