TaskRunner/TaskRunner/TaskManager.cs

37 lines
996 B
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
namespace TaskRunner
{
public class TaskManager
{
public Task RunFfmpeg()
{
var task = new TaskCompletionSource<bool>();
var process = new Process
{
StartInfo =
{
FileName = "ping",
Arguments = "google.com -t",
RedirectStandardOutput = true,
UseShellExecute = false
},
EnableRaisingEvents = true
};
process.OutputDataReceived += (sender, a) => Console.WriteLine(a.Data);
process.Start();
process.BeginOutputReadLine();
process.Exited += (sender, args) =>
{
task.SetResult(true);
process.Dispose();
};
return task.Task;
}
}
}