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;
しかし、新しいドキュメント オブジェクトを取得しようとすると、最後の行で次の例外が発生します。
前回の関数評価がタイムアウトしたため、関数評価が無効になりました。関数の評価を再度有効にするには、実行を続行する必要があります