- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在我的C#应用程序中使用一个以上的壁虎浏览器。
所以我做了什么:
FORM UI代码:
public partial class GeckoBrowserForm : Form
{
static GeckoBrowserForm()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
}
public GeckoBrowserForm(string xulRunnerPath, string url)
{
InitializeXulRunner(xulRunnerPath);
m_Url = url;
FormBorderStyle = FormBorderStyle.FixedToolWindow;
ShowInTaskbar = false;
StartPosition = FormStartPosition.Manual;
Location = new Point(0, 0);
Size = new Size(800, 800);
Done = false;
InitializeComponent();
}
private static void InitializeXulRunner(string path)
{
if (!Xpcom.IsInitialized)
{
Xpcom.Initialize(path);
}
}
protected override void OnLoad(EventArgs e)
{
m_GeckoWebBrowser.Parent = this;
m_GeckoWebBrowser.Dock = DockStyle.Fill;
m_GeckoWebBrowser.DocumentCompleted += (s, ee) =>
{
var geckoDomElement = m_GeckoWebBrowser.Document.DocumentElement;
if (geckoDomElement is GeckoHtmlElement)
{
GeckoHtmlElement element = (GeckoHtmlElement)geckoDomElement;
DocumentDomHtml = element.InnerHtml;
}
if (m_Url.Equals(m_GeckoWebBrowser.Document.Url.ToString(), StringComparison.OrdinalIgnoreCase))
{
Done = true;
}
};
m_GeckoWebBrowser.Navigate(m_Url);
}
if (Xpcom.IsInitialized)
{
Xpcom.Shutdown();
}
using (GeckoBrowserForm geckoBrowserForm = new GeckoBrowserForm(XulRunnerPath, propertyBag.ResponseUri.ToString()))
{
geckoBrowserForm.Show();
while (!geckoBrowserForm.Done)
{
Application.DoEvents();
}
string html = geckoBrowserForm.DocumentDomHtml;
if (!string.IsNullOrEmpty(html))
{
propertyBag.GetResponse = () => new MemoryStream(Encoding.UTF8.GetBytes(html));
}
base.Process(crawler, propertyBag);
}
Xpcom.Shutdown();
之后,我将无法再使用
Xpcom.Initialize(path);
。程序刚刚停止,没有任何错误。
public static void AssertCorrectThread()
{
if (Thread.CurrentThread.ManagedThreadId != _XpcomThreadId)
{
throw new InvalidOperationException("GeckoFx can only be called from the same thread on which it was initialized (normally the UI thread).");
}
}
最佳答案
看来这仍然是一个问题,在单元测试中非常重要。运行所有单元测试(从初始化开始),一切都很好。尝试再次运行它们,根据xpCom的状态,您可能会遇到问题,因为无法关闭。
类似的问题在这里:Using GeckoFX in a multithreaded application
关于c# - 使用Xpcom.Shutdown(),Xpcom.Initialize(path)后的GeckoFx不能再使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20813582/
假设我的 Linux 系统中运行着 20 个进程/deqamons,与 SHUTDOWN 相比,HALT 对我的进程/守护进程的影响有何不同 最佳答案 通常,人们使用 shutdown command
我无法理解差异。帮我看看这个区别。而ProcessPoolExecutor呢,他的行为是一样的吗? def func(task): do_something(task) tasks = [ta
在某个时候,在代码推送后不久,我们看到我们的 Web 应用程序多次重启,但没有任何日志记录表明存在任何问题。所以我找到了这篇文章:http://weblogs.asp.net/scottgu/4331
这个问题已经有答案了: Difference between shutdown and shutdownNow of Executor Service (3 个回答) 已关闭 4 年前。 以下是Exe
这个问题在这里已经有了答案: close vs shutdown socket? (9 个回答) 关闭 5 年前。 在此 MSDN 页面上: Sending and Receiving Data o
我想知道使用elasticsearch shutdown API和终止elasticsearch进程(ctrl + c)之间的区别。我实际上不以正常关闭为答案,因为我想知道发出关闭API调用时ES实际
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
Java 定时器调度任务:servive JVM 关闭? Timer timer = new Timer(); timer.scheduleAtFixedRate(...) JVM关闭后,调度的任务还
这个问题已经有答案了: Difference between shutdown and shutdownNow of Executor Service (3 个回答) 已关闭 5 年前。 我正在检查j
我正在 Windows 10 上的 CPython 3.7 中实现一个 Server 类,其中使用永久启动服务的 Server.serve 方法和 Server.shutdown code> 停止服务
为了避免延长等待时间,建议您在调用 awaitTermination() 之前先调用 shutdown(),因为后者不适合杀死执行者。但是,为了等待任务完成,您是否应该使用 invokeAll() 来
我正在用 Python 为老式计算机系统编写一个模拟器,在摆脱停止状态后尝试“重新启动”模拟器核心线程时,我遇到了一些抛出异常的问题。 “运行处理器”方法是一个更大类的一部分,如下所示: def ru
我有以下代码,用于在端口 8000 上运行本地 HTTP 服务器: # Omitted imports and irrelevant things for brevity. class Threade
import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util
我制作了一个程序,它会在设定的时间后关闭 PC。用户使用 2 个旋转框(一个用于小时,另一个用于分钟)输入时间,然后我将它转换为毫秒: ms = (ui->hBox->text().toInt() *
class System { public: virtual ~System() final { Shutdown(); }; virtual void Shu
看下面的代码: public void pinger() { ScheduledThreadPoolExecutor executor = new Schedule
我开发了一个小型 Java 应用程序,在其中使用 Quartz.jar 库。 但是当执行我的应用程序并调用 Quartz 时,我在控制台中收到以下错误消息: org.quartz.SchedulerE
我有 parking 系统的代码。当空格数超过 20 时,它会发送错误消息,因为 20 是空格的限制。我想在此之后尝试关闭程序。 我已尝试做您可以在 Python 中做的事情。这是: import s
我们在 RHEL (jdk 1.7.. 51) 上使用 Neo4j2.0.1 - 我们在一个同步线程上调用 GraphDatabaseService.shutDown(),并且此方法永远不会返回或引发
我是一名优秀的程序员,十分优秀!