我有这个代码片段需要检索 iframe 的文档对象并将其保存在一个对象中。
//just a wrapper object to store the document object
DocObj obj = new DocObj(HtmlDoc);
ManualResetEvent aDoneEvents = new ManualResetEvent(false);
string errorMessage = "";
Thread aThread = new Thread(() =>
{
try
{
//finding the iframe element in the current document
IHTMLElement IElem = LocatorBuilder.GetLocator(Target)
.Find(this.HTMLDoc);
obj.HTMLDoc = (IElem as HTMLIFrame).document as HTMLDocument;
}
catch (Exception e)
{
errorMessage = e.Message;
}
aDoneEvents.Set();
});
aThread.SetApartmentState(ApartmentState.STA);
aThread.IsBackground = true;
aThread.Start();
aDoneEvents.WaitOne();
if (errorMessage != "")
{
throw new Exception(errorMessage);
}
HtmlDoc = obj.HTMLDoc;
但是当我尝试检索新的文档对象时,我在最后一行得到了这个异常:
函数评估已禁用,因为之前的函数评估超时。您必须继续执行才能重新启用函数评估