C# 以下流程之间的区别是什么?

C# 以下流程之间的区别是什么?,c#,winforms,process,C#,Winforms,Process,此进程正在从我的应用程序“独立”运行。我可以在脚本运行时使用我的表单,而不是等待退出 string strCmdText = "some command line script"; System.Diagnostics.Process.Start("CMD.exe", strCmdText); 但这一个会在我的表单中停止进程,直到命令行窗口关闭: Process p = new Process(); p.StartInfo.Verb = "runas"; p.StartInfo.FileNam

此进程正在从我的应用程序“独立”运行。我可以在脚本运行时使用我的表单,而不是等待退出

string strCmdText = "some command line script";
System.Diagnostics.Process.Start("CMD.exe", strCmdText);
但这一个会在我的表单中停止进程,直到命令行窗口关闭:

Process p = new Process();
p.StartInfo.Verb = "runas";
p.StartInfo.FileName = cmd.exe;
p.Start();

在我看来,两者似乎都是相同的
process.start()
。那么区别是什么呢?

它们非常相似,但却不相同

这里是如何

构造函数将第二个参数设置为非属性的参数字符串。而且,

public static Process Start(ProcessStartInfo startInfo)
{
     Process process = new Process();
     if (startInfo == null) throw new ArgumentNullException("startInfo");
     process.StartInfo = startInfo;
     if (process.Start()) {
         return process;
     }
     return null;
}
从它的文档中可以看到

重载将资源与新的
进程
组件相关联。如果
进程已在运行,未启动其他进程。
而是重用现有的流程资源,并且没有新的
流程
组件已创建。在这种情况下,不返回新的
Process
component,
Start
向调用过程返回
null

public static Process Start(ProcessStartInfo startInfo)
{
     Process process = new Process();
     if (startInfo == null) throw new ArgumentNullException("startInfo");
     process.StartInfo = startInfo;
     if (process.Start()) {
         return process;
     }
     return null;
}