我希望从winforms按钮执行exe程序。我使用下面的代码工作。问题是winform进入阻塞状态,在exe程序关闭之前我无法与它进行交互。我想与winform和执行的程序进行交互。
如何使执行的程序成为非模态的?
public static void ExecuteCommand(string workingDirectory,
string cvsExePath, string arguments)
{
ProcessStartInfo exeProcess = new ProcessStartInfo(cvsExePath
, " " + arguments.Trim());
exeProcess.WorkingDirectory = workingDirectory;
exeProcess.UseShellExecute = false;
exeProcess.RedirectStandardOutput = false;
exeProcess.RedirectStandardError = true;
exeProcess.CreateNoWindow = false;
Process proc = Process.Start(exeProcess);
}
答案 0 :(得分:3)
你应该创建一个线程,线程执行这个exe
这是如何创建线程: How to: Create and Terminate Threads (C# Programming Guide)