![](/img/trans.png)
[英]Process.Start(“IEXPLORE.EXE”) immediately fires the Exited event after launch.. why?
[英]C# process start firefox.exe fires the exited immediately after launch
与Process.Start(“ IEXPLORE.EXE”)类似, 启动后立即触发Exited事件。为什么?
-nomerge选项似乎不适用于Firefox。
更新:
这是控制台应用程序中C#代码的预览
static bool exitCalled = false;
static string baseUrl = <some url to display in the browser>;
var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "Firefox.exe"
Arguments = " -url " + baseUrl + " -no-remote -P MyProfile "
}
}
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(delegate(Object o, EventArgs e)
{
// process has exited
Console.WriteLine("Exited event called");
Console.ReadLine();
exitCalled = true;
}
process.Start();
while (!exitCalled)
{
Thread.Sleep(100);
}
运行这段代码会在调用浏览器之前显示“已退出事件已调用”消息。
那是因为-nomerge
是IE特定的程序参数,因此对于firefox,您需要使用-no-remote
。 您还需要将-P
程序参数传递给它,因为不建议您使用默认配置文件启动另一个firefox进程。 请参阅以下有关启动新FireFox实例的链接:
http://kb.mozillazine.org/Opening_a_new_instance_of_Firefox_with_another_profile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.