我正在运行一个进程,点击我的WPF应用程序的按钮,如下所示:
private void btnGetValues_Click(object sender, RoutedEventArgs e)
{
string arg1 = "1";
Process p1 = new Process();
p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p1.StartInfo.FileName = "myexe.exe";
p1.StartInfo.Arguments = arg1;
p1.StartInfo.UseShellExecute = false;
p1.StartInfo.RedirectStandardOutput = true;
p1.StartInfo.RedirectStandardInput = true;
p1.StartInfo.RedirectStandardError = true;
p1.Start();
//while (!p1.HasExited)
//{
//}
MessageBox.Show(p1.StandardOutput.ReadToEnd());
}
问题是,即使在流程执行之后,按钮仍会继续保持在单击状态。可能是什么问题?