U
Ulf Bietz
I need some help to understand a specific threading problem :
I wrote a function "BrowserObjects()" for testing webcontent.
....
IHTMLDocument3 currentDoc = (IHTMLDocument3)ObjectFromLResult(lRes, ref
IID_IHTMLDocument,0);
IHTMLElementCollection frameCol = currentDoc.getElementsByTagName("FRAME");
foreach (IHTMLElement element in frameCol)
{
if (element is IHTMLElement)
{
DispHTMLFrameElement frameElement = (DispHTMLFrameElement)element;
IHTMLWindow2 newWindow = frameElement.contentWindow;
//InvalidCastException, if called in separate thread?
....
}
}
....
no problem, except when I try the following :
Thread secThread = new Thread(new ThreadStart(RunWebTest);
secThread.Start();
public void RunWebTest()
{
...
BrowserObjects();
...
}
as soon as I call the function in a separate thread, it raises a
"InvalidCastException : Schnittstelle wird nicht unterstützt." (german VS
..NET, would be Interface not supported/implemented I guess)
Could someone explain me why this Exception is only raised when I called in
a new thread?
And if it's a general interface/threading problem, why does it never happen
on IHTMLDocument3 ?
Only the call the IHTMLWindow2 raises the exception.
thx
Ulf
I wrote a function "BrowserObjects()" for testing webcontent.
....
IHTMLDocument3 currentDoc = (IHTMLDocument3)ObjectFromLResult(lRes, ref
IID_IHTMLDocument,0);
IHTMLElementCollection frameCol = currentDoc.getElementsByTagName("FRAME");
foreach (IHTMLElement element in frameCol)
{
if (element is IHTMLElement)
{
DispHTMLFrameElement frameElement = (DispHTMLFrameElement)element;
IHTMLWindow2 newWindow = frameElement.contentWindow;
//InvalidCastException, if called in separate thread?
....
}
}
....
no problem, except when I try the following :
Thread secThread = new Thread(new ThreadStart(RunWebTest);
secThread.Start();
public void RunWebTest()
{
...
BrowserObjects();
...
}
as soon as I call the function in a separate thread, it raises a
"InvalidCastException : Schnittstelle wird nicht unterstützt." (german VS
..NET, would be Interface not supported/implemented I guess)
Could someone explain me why this Exception is only raised when I called in
a new thread?
And if it's a general interface/threading problem, why does it never happen
on IHTMLDocument3 ?
Only the call the IHTMLWindow2 raises the exception.
thx

Ulf