Valoda

Process.RunAsync Method

Definition

Overloads

Name Description
RunAsync(ProcessStartInfo, CancellationToken)

Asynchronously starts the process described by startInfo, waits for it to exit, and returns its exit status.

RunAsync(String, IEnumerable<String>, Boolean, CancellationToken)

Asynchronously starts a process with the specified file name and optional arguments, waits for it to exit, and returns its exit status.

RunAsync(ProcessStartInfo, CancellationToken)

Source:
Process.Scenarios.cs

Asynchronously starts the process described by startInfo, waits for it to exit, and returns its exit status.

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

Parameters

startInfo
ProcessStartInfo

The ProcessStartInfo that contains the information used to start the process.

cancellationToken
CancellationToken

A token to cancel the asynchronous operation. If the token is canceled, the process is killed.

Returns

A task that represents the asynchronous operation. The value of the task contains the exit status of the process. If the process is killed due to cancellation, Canceled is true.

Attributes

Exceptions

startInfo is null.

UseShellExecute is set to true.

-or-

RedirectStandardInput, RedirectStandardOutput, or RedirectStandardError is set to true. Use the corresponding standard handle properties to supply handles instead.

Applies to

RunAsync(String, IEnumerable<String>, Boolean, CancellationToken)

Source:
Process.Scenarios.cs

Asynchronously starts a process with the specified file name and optional arguments, waits for it to exit, and returns its exit status.

[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Threading.Tasks.Task<System.Diagnostics.ProcessExitStatus> RunAsync(string fileName, System.Collections.Generic.IEnumerable<string>? arguments = default, bool silent = false, System.Threading.CancellationToken cancellationToken = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member RunAsync : string * seq<string> * bool * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Diagnostics.ProcessExitStatus>
Public Shared Function RunAsync (fileName As String, Optional arguments As IEnumerable(Of String) = Nothing, Optional silent As Boolean = false, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ProcessExitStatus)

Parameters

fileName
String

The name of the executable to start.

arguments
IEnumerable<String>

The command-line arguments to pass to the process. Pass null or an empty sequence to start the process without additional arguments.

silent
Boolean

When true, redirects standard input, output, and error to the null device, ensuring the process produces no visible console output. When false, the process inherits standard handles from the parent.

cancellationToken
CancellationToken

A token to cancel the asynchronous operation. If the token is canceled, the process is killed.

Returns

A task that represents the asynchronous operation. The value of the task contains the exit status of the process. If the process is killed due to cancellation, Canceled is true.

Attributes

Exceptions

fileName is null.

fileName is empty.

Applies to