Partager via


PowerShell.StopAsync(AsyncCallback, Object) Method

Definition

Stop a PowerShell command asynchronously. Use await to wait for the command to stop.

public System.Threading.Tasks.Task StopAsync (AsyncCallback callback, object state);
member this.StopAsync : AsyncCallback * obj -> System.Threading.Tasks.Task
Public Function StopAsync (callback As AsyncCallback, state As Object) As Task

Parameters

callback
AsyncCallback

An AsyncCallback to call once the command is invoked. Note: when using this API in script, don't pass in a delegate that is cast from a script block. The callback could be invoked from a thread without a default Runspace and a delegate cast from a script block would fail in that case.

state
Object

A user supplied state to call the callback with.

Returns

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

Exceptions

Object is disposed.

Remarks

If the command is not started, the state of the PowerShell instance is changed to Stopped and corresponding events will be raised.

Applies to