using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Extensions
{
///
/// Extension methods for .
///
public static class ProcessExtensions
{
///
/// Asynchronously wait for the process to exit.
///
/// The process to wait for.
/// The duration to wait before cancelling waiting for the task.
/// A task that will complete when the process has exited, cancellation has been requested, or an error occurs.
/// The timeout ended.
public static async Task WaitForExitAsync(this Process process, TimeSpan timeout)
{
using (var cancelTokenSource = new CancellationTokenSource(timeout))
{
await process.WaitForExitAsync(cancelTokenSource.Token).ConfigureAwait(false);
}
}
}
}