Język

Process.RunAsync Metoda

Definicja

Przeciążenia

Nazwisko Opis
RunAsync(ProcessStartInfo, CancellationToken)

Asynchronicznie uruchamia proces opisany przez startInfo, czeka na zakończenie i zwraca stan zakończenia.

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

Asynchronicznie rozpoczyna proces z określoną nazwą pliku i opcjonalnymi argumentami, czeka na zakończenie i zwraca stan zakończenia.

RunAsync(ProcessStartInfo, CancellationToken)

Źródło:
Process.Scenarios.cs

Asynchronicznie uruchamia proces opisany przez startInfo, czeka na zakończenie i zwraca stan zakończenia.

[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)

Parametry

startInfo
ProcessStartInfo

Element ProcessStartInfo zawierający informacje używane do rozpoczęcia procesu.

cancellationToken
CancellationToken

Token umożliwiający anulowanie operacji asynchronicznej. Jeśli token zostanie anulowany, proces zostanie zabity.

Zwraca

Zadanie reprezentujące operację asynchroniczną. Wartość zadania zawiera stan zakończenia procesu. Jeśli proces zostanie zabity z powodu anulowania, Canceled to .true

Atrybuty

Wyjątki

Parametr startInfo ma wartość null.

UseShellExecute jest ustawiony na true.

— lub —

RedirectStandardInput, RedirectStandardOutputlub RedirectStandardError ma ustawioną wartość true. Użyj odpowiednich standardowych właściwości dojścia, aby podać uchwyty.

Dotyczy

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

Źródło:
Process.Scenarios.cs

Asynchronicznie rozpoczyna proces z określoną nazwą pliku i opcjonalnymi argumentami, czeka na zakończenie i zwraca stan zakończenia.

[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)

Parametry

fileName
String

Nazwa pliku wykonywalnego do uruchomienia.

arguments
IEnumerable<String>

Argumenty wiersza polecenia, które mają być przekazywane do procesu. Przekaż null lub pustą sekwencję, aby rozpocząć proces bez dodatkowych argumentów.

silent
Boolean

Gdy trueprogram przekierowuje standardowe dane wejściowe, wyjściowe i błędy do urządzenia o wartości null, upewniając się, że proces nie generuje widocznych danych wyjściowych konsoli. Gdy falseproces dziedziczy standardowe dojścia z elementu nadrzędnego.

cancellationToken
CancellationToken

Token umożliwiający anulowanie operacji asynchronicznej. Jeśli token zostanie anulowany, proces zostanie zabity.

Zwraca

Zadanie reprezentujące operację asynchroniczną. Wartość zadania zawiera stan zakończenia procesu. Jeśli proces zostanie zabity z powodu anulowania, Canceled to .true

Atrybuty

Wyjątki

Parametr fileName ma wartość null.

fileName jest pusta.

Dotyczy