C# Process <instance>.StandardOutput InvalidOperationException "Cannot mix synchronous and asynchron
Posted
by Rahul2047
on Stack Overflow
See other posts from Stack Overflow
or by Rahul2047
Published on 2010-04-21T07:35:42Z
Indexed on
2010/04/21
7:43 UTC
Read the original article
Hit count: 387
I tried this
myProcess = new Process();
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
myProcess.StartInfo.FileName = "Hello.exe";
myProcess.StartInfo.Arguments ="-say Hello";
myProcess.StartInfo.UseShellExecute = false;
myProcess.OutputDataReceived += new DataReceivedEventHandler(myProcess_OutputDataReceived);
myProcess.ErrorDataReceived += new DataReceivedEventHandler(myProcess_OutputDataReceived);
myProcess.Exited += new EventHandler(myProcess_Exited);
myProcess.EnableRaisingEvents = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.RedirectStandardError = true;
myProcess.StartInfo.ErrorDialog = true;
myProcess.StartInfo.WorkingDirectory = "D:\\Program Files\\Hello";
myProcess.Start();
myProcess.BeginOutputReadLine();
myProcess.BeginErrorReadLine();
Then I am getting this error..
My process takes very long to complete, so I need to show progress in runtime.
© Stack Overflow or respective owner