Sprog

Process.WaitForExitStatusAsync(CancellationToken) Method

Definition

Waits asynchronously for the process to exit.

[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public System.Threading.Tasks.Task<System.Diagnostics.ProcessExitStatus> WaitForExitStatusAsync(System.Threading.CancellationToken cancellationToken = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
member this.WaitForExitStatusAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Diagnostics.ProcessExitStatus>
Public Function WaitForExitStatusAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of ProcessExitStatus)

Parameters

cancellationToken
CancellationToken

A cancellation token that can be used to cancel the wait operation.

Returns

A task that represents the asynchronous wait operation. The task result contains the exit status of the process.

Attributes

Exceptions

There is no process associated with this object, or the process handle or exit status is unavailable.

The process object has been disposed.

The process is on a remote computer.

The current platform is not supported, or, on Unix, the process is not a child process.

The cancellationToken was canceled. The exception is stored in the returned task.

Remarks

When the cancellation token is canceled, the method stops waiting and throws OperationCanceledException. The process isn't terminated and continues running. To terminate the process on cancellation instead, call WaitForExitOrKillOnCancellationAsync on SafeHandle.

On Unix, obtaining the exit status is supported only for child processes.

Applies to