hujanais
January 1st, 2005, 05:55 PM
Hi there,
I have an application written in C#.NET that uses the AxWebBrowser component. The program basically can navigate to some webpage and automatically parse the HTML tags and fill up some forms and send the form. This program has a worker thread that continously polls the webpages for data changes and when certain conditions are met, the thread "presses" a button on the webpage to get more data. At this point, everything still works very well.
The problem occurs when after the new data has been updated on the screen, no documentcomplete event is fired so my thread function essentially wants to do a
IHTMLDocument2 htmlDoc = (IHTMLDocument2)axWebBrowser1.Document; and reparse the data. However, to my surprise, the axWebBrowser1 object is undefined when it is trying to be used from the thread.
I tried using delegates but the problem is still not solved. The axWebBrowser1 control is always undefined.
delegate bool MyFunctionDelegate();
public bool MyFunction()
{
if( axWebBrowser1.InvokeRequired == false )
{
IHTMLDocument2 htmlDoc = (IHTMLDocument2)axWebBrowser1.Document;
// Do the parsing of the new data.
else
{
MyFunctionDelegate myDelegate = new MyFunctionDelegate (EnumerateBettingInputElements);
BeginInvoke(enumDelegate, new object[] {} );
}
return true;
}
Please help. I have tried many things and couldn't figure it out. Thanks in advance.
Sincerely,
Teik Lee
I have an application written in C#.NET that uses the AxWebBrowser component. The program basically can navigate to some webpage and automatically parse the HTML tags and fill up some forms and send the form. This program has a worker thread that continously polls the webpages for data changes and when certain conditions are met, the thread "presses" a button on the webpage to get more data. At this point, everything still works very well.
The problem occurs when after the new data has been updated on the screen, no documentcomplete event is fired so my thread function essentially wants to do a
IHTMLDocument2 htmlDoc = (IHTMLDocument2)axWebBrowser1.Document; and reparse the data. However, to my surprise, the axWebBrowser1 object is undefined when it is trying to be used from the thread.
I tried using delegates but the problem is still not solved. The axWebBrowser1 control is always undefined.
delegate bool MyFunctionDelegate();
public bool MyFunction()
{
if( axWebBrowser1.InvokeRequired == false )
{
IHTMLDocument2 htmlDoc = (IHTMLDocument2)axWebBrowser1.Document;
// Do the parsing of the new data.
else
{
MyFunctionDelegate myDelegate = new MyFunctionDelegate (EnumerateBettingInputElements);
BeginInvoke(enumDelegate, new object[] {} );
}
return true;
}
Please help. I have tried many things and couldn't figure it out. Thanks in advance.
Sincerely,
Teik Lee