473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to wait for window to load (threading)?

Say I open an IE window and call the Navigate() method. A web page opens.
I use a delegate to capture the DocumentComplete and NavigateComplete2
events. However, they fire slightly before the page completely loads. This
article addresses the above issues for OnBeforeNavigate2 event:
http://www.codeproject.com/buglist/i...&select=408890. I
changed it to work with DocumentComplete(), which seems to work well for the
ActiveX object.

Problem is that I need access to an actual IE window, not the ActiveX object
on a form. So when I marshall the InternetExplorer object:

ie = new SHDocVw.InternetExplorerClass();
ie = (SHDocVw.InternetExplorerClass)
System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(
axWebBrowser1.GetOcx(),
typeof(SHDocVw.InternetExplorerClass)
);

I end up with the page opening in the form, where the ActiveX object opened
it. This causes rendering problems such as JS script errors and such.

My question is how can I wait for the webpage to completely load? I'm open
to suggestions.

Thanks,
Brett
Nov 17 '05 #1
4 6556
hi
use the following code after using navigate and before using delegate

while(ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE )


hope this will help u
with regards
saish

"Brett" <no@spam.com> wrote in message news:uX**************@TK2MSFTNGP12.phx.gbl...
Say I open an IE window and call the Navigate() method. A web page opens.
I use a delegate to capture the DocumentComplete and NavigateComplete2
events. However, they fire slightly before the page completely loads. This
article addresses the above issues for OnBeforeNavigate2 event:
http://www.codeproject.com/buglist/i...&select=408890. I
changed it to work with DocumentComplete(), which seems to work well for the
ActiveX object.

Problem is that I need access to an actual IE window, not the ActiveX object
on a form. So when I marshall the InternetExplorer object:

ie = new SHDocVw.InternetExplorerClass();
ie = (SHDocVw.InternetExplorerClass)
System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(
axWebBrowser1.GetOcx(),
typeof(SHDocVw.InternetExplorerClass)
);

I end up with the page opening in the form, where the ActiveX object opened
it. This causes rendering problems such as JS script errors and such.

My question is how can I wait for the webpage to completely load? I'm open
to suggestions.

Thanks,
Brett

Nov 17 '05 #2
This goes into an infinite loop. The current thread never gives control
back to IE because it is always looping on the condition. I've also tried
it with Application.DoEvents(), which doesn't help.

while(IE_Inst.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE ){
Debug.WriteLine("In while loop, IE_Inst.ReadyState = " +
IE_Inst.ReadyState);
Application.DoEvents();}

Brett
"Saish" <sa***@nannacomputers.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
hi
use the following code after using navigate and before using delegate

while(ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE )

hope this will help u
with regards
saish

"Brett" <no@spam.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Say I open an IE window and call the Navigate() method. A web page opens.
I use a delegate to capture the DocumentComplete and NavigateComplete2
events. However, they fire slightly before the page completely loads.
This
article addresses the above issues for OnBeforeNavigate2 event:
http://www.codeproject.com/buglist/i...&select=408890. I
changed it to work with DocumentComplete(), which seems to work well for
the
ActiveX object.

Problem is that I need access to an actual IE window, not the ActiveX
object
on a form. So when I marshall the InternetExplorer object:

ie = new SHDocVw.InternetExplorerClass();
ie = (SHDocVw.InternetExplorerClass)
System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(
axWebBrowser1.GetOcx(),
typeof(SHDocVw.InternetExplorerClass)
);

I end up with the page opening in the form, where the ActiveX object
opened
it. This causes rendering problems such as JS script errors and such.

My question is how can I wait for the webpage to completely load? I'm
open
to suggestions.

Thanks,
Brett


Nov 17 '05 #3
This seems to be doing the trick. I'm putting it in the same place you
mentioned previously.

private delegate void DelegateWasteSomeTime();
.....

//placed in DocumentComplete event before next navigation. Allows current
page to fully load.
DelegateWasteSomeTime wstdel = new
DelegateWasteSomeTime(this.WasteSomeTime);
wstdel.BeginInvoke(null, null);

private void WasteSomeTime()
{
System.Threading.Thread.Sleep(2000);
}

Brett

"Brett" <no@spam.com> wrote in message
news:OB*************@TK2MSFTNGP14.phx.gbl...
This goes into an infinite loop. The current thread never gives control
back to IE because it is always looping on the condition. I've also tried
it with Application.DoEvents(), which doesn't help.

while(IE_Inst.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE ){
Debug.WriteLine("In while loop, IE_Inst.ReadyState = " +
IE_Inst.ReadyState);
Application.DoEvents();}

Brett
"Saish" <sa***@nannacomputers.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
hi
use the following code after using navigate and before using delegate

while(ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE )

hope this will help u
with regards
saish

"Brett" <no@spam.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Say I open an IE window and call the Navigate() method. A web page
opens.
I use a delegate to capture the DocumentComplete and NavigateComplete2
events. However, they fire slightly before the page completely loads.
This
article addresses the above issues for OnBeforeNavigate2 event:
http://www.codeproject.com/buglist/i...&select=408890. I
changed it to work with DocumentComplete(), which seems to work well for
the
ActiveX object.

Problem is that I need access to an actual IE window, not the ActiveX
object
on a form. So when I marshall the InternetExplorer object:

ie = new SHDocVw.InternetExplorerClass();
ie = (SHDocVw.InternetExplorerClass)
System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(
axWebBrowser1.GetOcx(),
typeof(SHDocVw.InternetExplorerClass)
);

I end up with the page opening in the form, where the ActiveX object
opened
it. This causes rendering problems such as JS script errors and such.

My question is how can I wait for the webpage to completely load? I'm
open
to suggestions.

Thanks,
Brett

Nov 17 '05 #4
Scratch that. It's flying right through that line. Even if I do spin off a
new thread, I'd tie the current thread up by waiting for the new thread to
complete some type of loop. I'd be in the same situation.

Brett

"Brett" <no@spam.com> wrote in message
news:e5**************@TK2MSFTNGP15.phx.gbl...
This seems to be doing the trick. I'm putting it in the same place you
mentioned previously.

private delegate void DelegateWasteSomeTime();
....

//placed in DocumentComplete event before next navigation. Allows current
page to fully load.
DelegateWasteSomeTime wstdel = new
DelegateWasteSomeTime(this.WasteSomeTime);
wstdel.BeginInvoke(null, null);

private void WasteSomeTime()
{
System.Threading.Thread.Sleep(2000);
}

Brett

"Brett" <no@spam.com> wrote in message
news:OB*************@TK2MSFTNGP14.phx.gbl...
This goes into an infinite loop. The current thread never gives control
back to IE because it is always looping on the condition. I've also
tried it with Application.DoEvents(), which doesn't help.

while(IE_Inst.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE ){
Debug.WriteLine("In while loop, IE_Inst.ReadyState = " +
IE_Inst.ReadyState);
Application.DoEvents();}

Brett
"Saish" <sa***@nannacomputers.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
hi
use the following code after using navigate and before using delegate

while(ie.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE )

hope this will help u
with regards
saish

"Brett" <no@spam.com> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
Say I open an IE window and call the Navigate() method. A web page
opens.
I use a delegate to capture the DocumentComplete and NavigateComplete2
events. However, they fire slightly before the page completely loads.
This
article addresses the above issues for OnBeforeNavigate2 event:
http://www.codeproject.com/buglist/i...&select=408890. I
changed it to work with DocumentComplete(), which seems to work well for
the
ActiveX object.

Problem is that I need access to an actual IE window, not the ActiveX
object
on a form. So when I marshall the InternetExplorer object:

ie = new SHDocVw.InternetExplorerClass();
ie = (SHDocVw.InternetExplorerClass)
System.Runtime.InteropServices.Marshal.CreateWrapp erOfType(
axWebBrowser1.GetOcx(),
typeof(SHDocVw.InternetExplorerClass)
);

I end up with the page opening in the form, where the ActiveX object
opened
it. This causes rendering problems such as JS script errors and such.

My question is how can I wait for the webpage to completely load? I'm
open
to suggestions.

Thanks,
Brett


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mark English | last post by:
Every once in a while since I moved to Python 2.4 I've been seeing the following exception in threading.py Condition: File "mctest3.py", line 1598, in WaitForMessages...
6
by: SP | last post by:
Hi, I want to add wait cursor code whenever page is post back. Page may be post back on my user control's or on change of dropdown or on click of any button on page. so is there any common...
9
by: John Walker | last post by:
Hi, I have a datagrid with a radiobutton template column, with AutoPostBack set to TRUE. When the user clicks on a radiobutton the application will PostBack, and in the PostBack there will be...
18
by: Coder | last post by:
Howdy everybody! How do I do the following... while (myVary != true){}; Obviously I do not want to use 100% of the processor to stay in this infinite loop till myVar == true. But wait do I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.