I find a other method, it work.
But, I would have liked to know how to do with BackgroundWorker.
public void Process_Ex(string fileName, string arguments)
{
var psi = new ProcessStartInfo(fileName, arguments);
psi.UseShellExecute = false;
psi.ErrorDialog = false;
psi.CreateNoWindow = true;
var encoding = Encoding.GetEncoding(850);
psi.StandardOutputEncoding = encoding;
psi.StandardErrorEncoding = encoding;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
var process = new Process();
process.EnableRaisingEvents = true;
process.StartInfo = psi;
process.Start();
process.OutputDataReceived += new
DataReceivedEventHandler(SortOutputHandler);
process.BeginOutputReadLine();
process.BeginErrorReadLine();
return;
}
void SortOutputHandler(object sender, DataReceivedEventArgs e)
{
Trace.WriteLine(e.Data);
this.BeginInvoke(new MethodInvoker(() =>
{
richTextBox1.AppendText(Environment.NewLine + e.Data ?? string.Empty);
}));
}