PowerShell.BeginInvoke Method

Definition

Overloads

BeginInvoke()

Invoke the Command asynchronously. Use EndInvoke() to obtain the output of the command.

BeginInvoke<T>(PSDataCollection<T>)

Invoke the Command asynchronously. Use EndInvoke() to obtain the output of the command.

BeginInvoke<T>(PSDataCollection<T>, PSInvocationSettings, AsyncCallback, Object)

Invoke the Command asynchronously. Use EndInvoke() to obtain the output of the command.

BeginInvoke<TInput,TOutput>(PSDataCollection<TInput>, PSDataCollection<TOutput>)

Invoke the Command asynchronously. When this method is used EndInvoke() returns a null buffer.

BeginInvoke<TInput,TOutput>(PSDataCollection<TInput>, PSDataCollection<TOutput>, PSInvocationSettings, AsyncCallback, Object)

Invoke the Command asynchronously and collect output data into the buffer output. When this method is used EndInvoke() returns a null buffer.

BeginInvoke()

Invoke the Command asynchronously. Use EndInvoke() to obtain the output of the command.

public IAsyncResult BeginInvoke ();
Returns
Exceptions

Cannot perform the operation because the command is already started. Stop the command and try the operation again. (or) No command is added.

Object is disposed.

BeginInvoke<T>(PSDataCollection<T>)

Invoke the Command asynchronously. Use EndInvoke() to obtain the output of the command.

public IAsyncResult BeginInvoke<T> (System.Management.Automation.PSDataCollection<T> input);
Type Parameters
T

Type of the input buffer

Parameters
input
PSDataCollection<T>

Input to the command. See remarks for more details.

Returns
Exceptions

Cannot perform the operation because the command is already started. Stop the command and try the operation again. (or) No command is added.

Object is disposed.

Remarks

When invoked using BeginInvoke, invocation doesn't finish until Input is closed. Caller of BeginInvoke must close the input buffer after all input has been written to input buffer. Input buffer is closed by calling Close() method.

        If you want this command to execute as a standalone cmdlet
        (that is, using command-line parameters only),
        be sure to call Close() before calling BeginInvoke().  Otherwise, 
        the command will be executed as though it had external input.  
        If you observe that the command isn't doing anything, 
        this may be the reason.

BeginInvoke<T>(PSDataCollection<T>, PSInvocationSettings, AsyncCallback, Object)

Invoke the Command asynchronously. Use EndInvoke() to obtain the output of the command.

public IAsyncResult BeginInvoke<T> (System.Management.Automation.PSDataCollection<T> input, System.Management.Automation.PSInvocationSettings settings, AsyncCallback callback, object state);
Type Parameters
T

Type of the input buffer

Parameters
input
PSDataCollection<T>

Input to the command. See remarks for more details.

settings
PSInvocationSettings

Invocation Settings.

callback
AsyncCallback

An AsyncCallback to call once the BeginInvoke completes.

state
Object

A user supplied state to call the callback with.

Returns
Exceptions

Cannot perform the operation because the command is already started. Stop the command and try the operation again. (or) No command is added.

Object is disposed.

Remarks

When invoked using BeginInvoke, invocation doesn't finish until Input is closed. Caller of BeginInvoke must close the input buffer after all input has been written to input buffer. Input buffer is closed by calling Close() method.

        If you want this command to execute as a standalone cmdlet
        (that is, using command-line parameters only),
        be sure to call Close() before calling BeginInvoke().  Otherwise, 
        the command will be executed as though it had external input.  
        If you observe that the command isn't doing anything, 
        this may be the reason.

BeginInvoke<TInput,TOutput>(PSDataCollection<TInput>, PSDataCollection<TOutput>)

Invoke the Command asynchronously. When this method is used EndInvoke() returns a null buffer.

public IAsyncResult BeginInvoke<TInput,TOutput> (System.Management.Automation.PSDataCollection<TInput> input, System.Management.Automation.PSDataCollection<TOutput> output);
Type Parameters
TInput

Type of input object(s) for the command invocation.

TOutput

Type of output object(s) expected from the command invocation.

Parameters
input
PSDataCollection<TInput>

Input to the command. See remarks for more details.

output
PSDataCollection<TOutput>

A buffer supplied by the user where output is collected.

Returns
Exceptions

Cannot perform the operation because the command is already started. Stop the command and try the operation again. (or) No command is added.

Object is disposed.

Remarks

When invoked using BeginInvoke, invocation doesn't finish until Input is closed. Caller of BeginInvoke must close the input buffer after all input has been written to input buffer. Input buffer is closed by calling Close() method.

        If you want this command to execute as a standalone cmdlet
        (that is, using command-line parameters only),
        be sure to call Close() before calling BeginInvoke().  Otherwise, 
        the command will be executed as though it had external input.  
        If you observe that the command isn't doing anything, 
        this may be the reason.

BeginInvoke<TInput,TOutput>(PSDataCollection<TInput>, PSDataCollection<TOutput>, PSInvocationSettings, AsyncCallback, Object)

Invoke the Command asynchronously and collect output data into the buffer output. When this method is used EndInvoke() returns a null buffer.

public IAsyncResult BeginInvoke<TInput,TOutput> (System.Management.Automation.PSDataCollection<TInput> input, System.Management.Automation.PSDataCollection<TOutput> output, System.Management.Automation.PSInvocationSettings settings, AsyncCallback callback, object state);
Type Parameters
TInput

Type of input object(s) for the command invocation.

TOutput

Type of output object(s) expected from the command invocation.

Parameters
input
PSDataCollection<TInput>

Input to the command. See remarks for more details.

output
PSDataCollection<TOutput>

A buffer supplied by the user where output is collected.

settings
PSInvocationSettings

Invocation Settings.

callback
AsyncCallback

An AsyncCallback to call once the BeginInvoke completes.

state
Object

A user supplied state to call the callback with.

Returns
Exceptions

Cannot perform the operation because the command is already started. Stop the command and try the operation again. (or) No command is added.

Object is disposed.

Remarks

When invoked using BeginInvoke, invocation doesn't finish until Input is closed. Caller of BeginInvoke must close the input buffer after all input has been written to input buffer. Input buffer is closed by calling Close() method.

        If you want this command to execute as a standalone cmdlet
        (that is, using command-line parameters only),
        be sure to call Close() before calling BeginInvoke().  Otherwise, 
        the command will be executed as though it had external input.  
        If you observe that the command isn't doing anything, 
        this may be the reason.