Process.RunAndCaptureTextAsync Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Overloads
| Naam | Description |
|---|---|
| RunAndCaptureTextAsync(ProcessStartInfo, CancellationToken) |
Asynchroon start het proces dat wordt beschreven door |
| RunAndCaptureTextAsync(String, IEnumerable<String>, CancellationToken) |
Asynchroon start een proces met de opgegeven bestandsnaam en optionele argumenten, legt de standaarduitvoer en fout vast, wacht tot deze is afgesloten en retourneert de vastgelegde tekst en afsluitstatus. |
RunAndCaptureTextAsync(ProcessStartInfo, CancellationToken)
- Bron:
- Process.Scenarios.cs
Asynchroon start het proces dat wordt beschreven door startInfo, legt de standaarduitvoer en -fout vast, wacht totdat het wordt afgesloten en retourneert de vastgelegde tekst en de afsluitstatus.
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Threading.Tasks.Task<System.Diagnostics.ProcessTextOutput> RunAndCaptureTextAsync(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 RunAndCaptureTextAsync : System.Diagnostics.ProcessStartInfo * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Diagnostics.ProcessTextOutput>
Public Shared Function RunAndCaptureTextAsync (startInfo As ProcessStartInfo, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ProcessTextOutput)
Parameters
- startInfo
- ProcessStartInfo
De ProcessStartInfo informatie die wordt gebruikt om het proces te starten.
- cancellationToken
- CancellationToken
Een token om de asynchrone bewerking te annuleren. Als het token wordt geannuleerd, wordt het proces beëindigd.
Retouren
Een taak die de asynchrone bewerking vertegenwoordigt. De waarde van de taak bevat de vastgelegde tekstuitvoer en de afsluitstatus van het proces.
- Kenmerken
Uitzonderingen
startInfo is null.
UseShellExecute is ingesteld op true.
– of –
RedirectStandardOutput of RedirectStandardError is niet ingesteld op true.
De cancellationToken bewerking is geannuleerd tijdens het lezen van de omgeleide streams.
Opmerkingen
Als annulering optreedt tijdens het lezen van de omgeleide streams, probeert de methode het proces te doden en genereert OperationCanceledException. Als annulering plaatsvindt nadat de streams volledig zijn gelezen, maar terwijl wordt gewacht tot het proces is afgesloten, wordt het proces beëindigd en is het geretourneerde ExitStatus proces ingesteld op true.Canceled
Van toepassing op
RunAndCaptureTextAsync(String, IEnumerable<String>, CancellationToken)
- Bron:
- Process.Scenarios.cs
Asynchroon start een proces met de opgegeven bestandsnaam en optionele argumenten, legt de standaarduitvoer en fout vast, wacht tot deze is afgesloten en retourneert de vastgelegde tekst en afsluitstatus.
[System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public static System.Threading.Tasks.Task<System.Diagnostics.ProcessTextOutput> RunAndCaptureTextAsync(string fileName, System.Collections.Generic.IEnumerable<string>? arguments = default, System.Threading.CancellationToken cancellationToken = default);
[<System.Runtime.Versioning.SupportedOSPlatform("maccatalyst")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
static member RunAndCaptureTextAsync : string * seq<string> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Diagnostics.ProcessTextOutput>
Public Shared Function RunAndCaptureTextAsync (fileName As String, Optional arguments As IEnumerable(Of String) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of ProcessTextOutput)
Parameters
- fileName
- String
De naam van het uitvoerbare bestand dat moet worden gestart.
- arguments
- IEnumerable<String>
De opdrachtregelargumenten die moeten worden doorgegeven aan het proces. Geef null of een lege reeks door om het proces te starten zonder extra argumenten.
- cancellationToken
- CancellationToken
Een token om de asynchrone bewerking te annuleren. Als het token wordt geannuleerd, wordt het proces beëindigd.
Retouren
Een taak die de asynchrone bewerking vertegenwoordigt. De waarde van de taak bevat de vastgelegde tekstuitvoer en de afsluitstatus van het proces.
- Kenmerken
Uitzonderingen
fileName is null.
fileName is leeg.
De cancellationToken bewerking is geannuleerd tijdens het lezen van de omgeleide streams.
Opmerkingen
Als annulering optreedt tijdens het lezen van de omgeleide streams, probeert de methode het proces te doden en genereert OperationCanceledException. Als annulering plaatsvindt nadat de streams volledig zijn gelezen, maar terwijl wordt gewacht tot het proces is afgesloten, wordt het proces beëindigd en is het geretourneerde ExitStatus proces ingesteld op true.Canceled