What's new

Web browser Pause?

tOxiC x

tOxiC x

Enthusiast
Frame In Gold Modder Seasoned Veteran
Messages
657
Reaction score
123
Points
165
Sin$
7
This is pretty simple but I want the most efficient way of doing this:

I have a web browser auto-browsing to a page. I want it to fully load that page before it continues to load the next one. So as soon as the browser is not busy, it will load the next one.

I could use the webBrowser1.IsBusy == true; but I can't seem to figure out a nice way to make it work flawlessly.

I wish there was a "when" statement so I could say:

when (webBrowser1.IsBusy == false)
webBrowser.Navigate("url");
 
tOxiC x

tOxiC x

Enthusiast
Frame In Gold Modder Seasoned Veteran
Messages
657
Reaction score
123
Points
165
Sin$
7
Yea but if I do that it will just skip that whole statement if it IS busy. I want it to wait until it is not busy.
 
Ibdc

Ibdc

VIP
VIP
Retired
Forum Addict MotM
Messages
4,969
Reaction score
2,193
Points
625
Sin$
0
WebBrowser1.Navigate("http://www.google.com");
while ((WebBrowser1.ReadyState != WebBrowserReadyState.Complete)) {
Application.DoEvents();
}
 
D

dschu012

Enthusiast
Frame In Gold Seasoned Veteran
Messages
757
Reaction score
380
Points
125
Sin$
0
Add a document complete event to the web browser control
Code:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{

webBrowser1.Navigate("url");
}
 
tOxiC x

tOxiC x

Enthusiast
Frame In Gold Modder Seasoned Veteran
Messages
657
Reaction score
123
Points
165
Sin$
7
I can't do that, it is not just going to 2 URL's, I need it to go to a few different ones one after the other.
 
D

dschu012

Enthusiast
Frame In Gold Seasoned Veteran
Messages
757
Reaction score
380
Points
125
Sin$
0
tOxiC x said:
I can't do that, it is not just going to 2 URL's, I need it to go to a few different ones one after the other.
Make a queue and dequeue the urls.... Or you can do conditional statements like
Code:
if (e.Url.ToString().Contains("www.xbox.com"))
webBrowser1.Navigate("www.google.com");
if (e.Url.ToString().Contains("www.google.com"))
webBrowser1.Navigate("www.yahoo.com");
 
L

Luxurious Meat

Enthusiast
Messages
610
Reaction score
124
Points
125
Sin$
0
Code:
string[] urls = new string[3] { "http://google.com", "http://yahoo.com", "http://msdn.com" };

int x = 0;
wb.Navigate(urls[0]);
while (true)
{
if (x == urls.Length) break;

if (wb.ReadyState == WebBrowserReadyState.Complete) { wb.Navigate(urls[x]); x++; }
else Application.DoEvents();
}
 
GoldBl4d3

GoldBl4d3

VIP
VIP
Retired
Programmer Mythical Veteran Legendary Veteran
Messages
3,785
Reaction score
1,452
Points
600
Sin$
0
nice lux, finally someone who understands this well. nice code. ps: no offence to the others
 
Top Bottom
Login
Register