src/FFmpeg.NET/Extensions/TaskExtensions.cs
/// <summary>
/// Waits asynchronously for the process to exit.
/// </summary>
/// <param name="process">The process to wait for cancellation.</param>
/// <param name="cancellationToken">A cancellation token. If invoked, the task will return 
/// immediately as canceled.</param>
/// <returns>A Task representing waiting for the process to end.</returns>
Waits asynchronously for the process to exit.
Waits asynchronously for the process to exit .
internal static Task WaitForExitAsync(this Process process, CancellationToken cancellationToken = default(CancellationToken))
        {
            var tcs = new TaskCompletionSource<object>();
            process.EnableRaisingEvents = true;
            process.Exited += (sender, args) => tcs.TrySetResult(null);
            if (cancellationToken != default(CancellationToken))
                cancellationToken.Register(tcs.SetCanceled);
            return tcs.Task;
        }
internal static Task WaitForExitAsync ( this Process process , CancellationToken cancellationToken = default ( CancellationToken ) ) { var tcs = new TaskCompletionSource < object > ( ) ; process . EnableRaisingEvents = true ; process . Exited += ( sender , args ) => tcs . TrySetResult ( null ) ; if ( cancellationToken != default ( CancellationToken ) ) cancellationToken . Register ( tcs . SetCanceled ) ; return tcs . Task ; }
Waits asynchronously for the process to exit.
Waits asynchronously for the process to exit .
A Task representing waiting for the process to end.
A Task representing waiting for the process to end .
Process
this
cancellationToken
CancellationToken
A cancellation token. If invoked, the task will return
immediately as canceled.
A cancellation token . If invoked the task will return immediately as canceled .
process
The process to wait for cancellation.
The process to wait for cancellation .