Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 3rd, 2008, 04:03 AM
slaterm61 slaterm61 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 slaterm61 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 44 sec
Reputation Power: 0
Problem with TWebBrowser Control and Threads

I am just new to Delphi Programmng and am having a problem with the TWebBrowser Control,

I have some code like this

WebBrowser1.Navigate('(some other url));
while Form1.WebBrowser1.Busy do
Application.ProcessMessages;
;

Do Some Stuff Here...

WebBrowser1.Navigate(some other url));
while Form1.WebBrowser1.Busy do
Application.ProcessMessages;
;
Do some more stuff here.

The problem is, it seems is that the WebBrowser Control seems to navigate to the first url as it is meant to, and then before first page has fully loaded and the code right after the WebBrowser1.Navigate is executed before the page has finished loading

Or it does not even get executed at all, and rather Navigates to the second URL and processes the second block of code.


Is this because the webrowser.navigate method causes a seperate thread to execute and program execution continues in the main thead before the webbrowser has finished downloading the page ?

It's confusing me a little bit

Thanks.


and

Reply With Quote
  #2  
Old May 3rd, 2008, 04:46 AM
parasaur parasaur is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 8 parasaur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 17 m 24 sec
Reputation Power: 0
It's just a guess but I would say that removing the

Application.Processmessages;

Might stop it from jumping from one to another.

Either that or you need some sort of control, probably a boolean variable to prevent the second process from working until the first has finished.

Something like..

WebBrowser1.Navigate('(some other url));
while Form1.WebBrowser1.Busy do begin
Process1Busy:=True;
Application.ProcessMessages;
end;
Process1Busy:=False;
;

Do Some Stuff Here...

if Process1Busy=False then
WebBrowser1.Navigate(some other url));
while Form1.WebBrowser1.Busy do
Application.ProcessMessages;
;
Do some more stuff here.

Reply With Quote
  #3  
Old May 3rd, 2008, 06:30 AM
slaterm61 slaterm61 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 slaterm61 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 44 sec
Reputation Power: 0
Problem with IWebBrowser

Thanks, i will give that a try

Quote:
Originally Posted by parasaur
It's just a guess but I would say that removing the

Application.Processmessages;

Might stop it from jumping from one to another.

Either that or you need some sort of control, probably a boolean variable to prevent the second process from working until the first has finished.

Something like..

WebBrowser1.Navigate('(some other url));
while Form1.WebBrowser1.Busy do begin
Process1Busy:=True;
Application.ProcessMessages;
end;
Process1Busy:=False;
;

Do Some Stuff Here...

if Process1Busy=False then
WebBrowser1.Navigate(some other url));
while Form1.WebBrowser1.Busy do
Application.ProcessMessages;
;
Do some more stuff here.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Problem with TWebBrowser Control and Threads


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway