언어

Process.RunAndCaptureTextAsync 메서드

정의

오버로드

속성 Description
RunAndCaptureTextAsync(ProcessStartInfo, CancellationToken)

설명한 startInfo프로세스를 비동기적으로 시작하고, 표준 출력 및 오류를 캡처하고, 종료될 때까지 기다린 다음, 캡처된 텍스트 및 종료 상태를 반환합니다.

RunAndCaptureTextAsync(String, IEnumerable<String>, CancellationToken)

지정된 파일 이름 및 선택적 인수를 사용하여 프로세스를 비동기적으로 시작하고, 표준 출력 및 오류를 캡처하고, 종료될 때까지 기다렸다가 캡처한 텍스트 및 종료 상태를 반환합니다.

RunAndCaptureTextAsync(ProcessStartInfo, CancellationToken)

Source:
Process.Scenarios.cs

설명한 startInfo프로세스를 비동기적으로 시작하고, 표준 출력 및 오류를 캡처하고, 종료될 때까지 기다린 다음, 캡처된 텍스트 및 종료 상태를 반환합니다.

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

매개 변수

startInfo
ProcessStartInfo

ProcessStartInfo 프로세스를 시작하는 데 사용되는 정보가 들어 있는 항목입니다.

cancellationToken
CancellationToken

비동기 작업을 취소하는 토큰입니다. 토큰이 취소되면 프로세스가 종료됩니다.

반품

비동기 작업을 나타내는 작업입니다. 태스크의 값에는 캡처된 텍스트 출력과 프로세스의 종료 상태가 포함됩니다.

특성

예외

startInfo은 null입니다.

UseShellExecute이 true로 설정됩니다.

또는

RedirectStandardOutput 또는 RedirectStandardError .로 true설정되지 않았습니다.

cancellationToken 리디렉션된 스트림을 읽는 동안 취소되었습니다.

설명

리디렉션된 스트림을 읽는 동안 취소가 발생하면 메서드는 프로세스를 종료하려고 시도하고 throw합니다 OperationCanceledException. 스트림을 완전히 읽은 후 취소가 발생하지만 프로세스가 종료되기를 기다리는 동안 취소가 발생하면 프로세스가 종료되고 반환 ExitStatus 된 내용이 로 true설정됩니다Canceled.

적용 대상

RunAndCaptureTextAsync(String, IEnumerable<String>, CancellationToken)

Source:
Process.Scenarios.cs

지정된 파일 이름 및 선택적 인수를 사용하여 프로세스를 비동기적으로 시작하고, 표준 출력 및 오류를 캡처하고, 종료될 때까지 기다렸다가 캡처한 텍스트 및 종료 상태를 반환합니다.

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

매개 변수

fileName
String

시작할 실행 파일의 이름입니다.

arguments
IEnumerable<String>

프로세스에 전달할 명령줄 인수입니다. 추가 인수 없이 프로세스를 시작하는 빈 시퀀스를 전달하거나 빈 시퀀스를 전달 null 합니다.

cancellationToken
CancellationToken

비동기 작업을 취소하는 토큰입니다. 토큰이 취소되면 프로세스가 종료됩니다.

반품

비동기 작업을 나타내는 작업입니다. 태스크의 값에는 캡처된 텍스트 출력과 프로세스의 종료 상태가 포함됩니다.

특성

예외

fileName은 null입니다.

fileName 가 비어 있습니다.

cancellationToken 리디렉션된 스트림을 읽는 동안 취소되었습니다.

설명

리디렉션된 스트림을 읽는 동안 취소가 발생하면 메서드는 프로세스를 종료하려고 시도하고 throw합니다 OperationCanceledException. 스트림을 완전히 읽은 후 취소가 발생하지만 프로세스가 종료되기를 기다리는 동안 취소가 발생하면 프로세스가 종료되고 반환 ExitStatus 된 내용이 로 true설정됩니다Canceled.

적용 대상