C# Process <instance>.StandardOutput InvalidOperationException "Cannot mix synchronous and asynchron
- by Rahul2047
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.