Share via


PowerShell.EndInvoke(IAsyncResult) Method

Definition

Waits for the pending asynchronous BeginInvoke to complete.

public:
 System::Management::Automation::PSDataCollection<System::Management::Automation::PSObject ^> ^ EndInvoke(IAsyncResult ^ asyncResult);
public System.Management.Automation.PSDataCollection<System.Management.Automation.PSObject> EndInvoke (IAsyncResult asyncResult);
member this.EndInvoke : IAsyncResult -> System.Management.Automation.PSDataCollection<System.Management.Automation.PSObject>
Public Function EndInvoke (asyncResult As IAsyncResult) As PSDataCollection(Of PSObject)

Parameters

asyncResult
IAsyncResult

Instance of IAsyncResult returned by BeginInvoke.

Returns

The output buffer created to hold the results of the asynchronous invoke, or null if the caller provided their own buffer.

Exceptions

asyncResult is a null reference.

asyncResult object was not created by calling BeginInvoke on this PowerShell instance.

The running PowerShell pipeline was stopped. This occurs when Stop() or StopAsync(AsyncCallback, Object) is called. To collect partial output in this scenario, supply a PSDataCollection<T> to BeginInvoke() for the output parameter and either add a handler for the DataAdding event or catch the exception and enumerate the object supplied.

Applies to