如果在单独的线程中启动,为什么 GeckoFX Navigate() 请求不起作用?
为什么这个有效,
private void buttonBoo_Click(object sender, EventArgs e)
{
GeckoBrowser.Navigate("http://www.google.com/");
}
而这个无效?
private void buttonBoo_Click(object sender, EventArgs e)
{
Thread thread = new Thread(delegate()
{
GeckoBrowser.Navigate("http://www.google.com/");
});
thread.Start();
}
Why does this work,
private void buttonBoo_Click(object sender, EventArgs e)
{
GeckoBrowser.Navigate("http://www.google.com/");
}
and this not?
private void buttonBoo_Click(object sender, EventArgs e)
{
Thread thread = new Thread(delegate()
{
GeckoBrowser.Navigate("http://www.google.com/");
});
thread.Start();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
GeckoBrowser 是一个 Windows 窗体控件。控件的属性和方法只能从创建控件的线程中调用。要从另一个线程对 Control 执行任何操作,您需要使用 Invoke 或 BeginInvoke 方法,例如
GeckoBrowser is a Windows Forms Control. A Control's properties and methods may be called only from the thread on which the Control was created. To do anything with a Control from another thread, you need to use the Invoke or BeginInvoke method, e.g.
请记住,由于底层引擎 XulRunner (XPCOM),GeckoFX 组件通常不是多线程的。这是因为 XulRunner 本身是一个单线程运行时。
Keep in mind that due to the underlying engine, XulRunner (XPCOM), the GeckoFX component is NOT generally multithreadable. This is because XulRunner, itself, is a single threaded runtime.
它不起作用,因为 Geckofx 本身不支持跨线程,如果您想要跨线程,您需要先调用它。
It does not work because Geckofx in itself doesn't support cross Threading if you want to do cross thread you will need to Invoke it first.