473,383 Members | 1,963 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,383 software developers and data experts.

How do I wait for a web page?

I am developing a stock market simulator using data from Yahoo's
Finance page. I am using a web browser control hosted on a form that
has a public method named GetPage(), which takes a URL. I want
GetPage() to call m_browser.Navigate() and then wait for the
DocumentComplete event. The DocumentComplete event handler will store
the inner text of the body of the returned document and then wake up
GetPage(), which will then return the text to its caller.

I thought I could use a ManualResetEvent object named m_dataReceived to

manage this. After Navigate(), I call m_dataReceived.Reset() and then
m_dataReceived.WaitOne(). In the DocumentComplete event handler, I
call m_dataReceived.Set(). However, the event handler never runs. If
I take out the events and just let things happen when they want to, I
get the data from the web page.
What am I doing wrong?
Thank you very much.
Rob Richardson

Dec 19 '06 #1
3 2950
Hi Rob,
if you just want to wait till the page is loaded, you can use the
GetReadyState function. I do this under vc, because of this I'm not sure
whether it works for .net, too.

Here my code:

m_browser.Navigate(ASPX_FILE, NULL, NULL, NULL, NULL);
const int READYSTATE_COMPLETE = 4;
while(m_browser.GetReadyState() == READYSTATE_COMPLETE)
{
Sleep(10);
}

//Do somthing

Best Regards
Marcel
Dec 19 '06 #2
Rob,

I would rather use WebClient. It does everything for you much easily and you
don't need to work with Events.

Some examples you may give a try:

http://www.codersource.net/csharp_screen_scraping.html
http://www.codeproject.com/csharp/uploadfileex.asp

Best,

Robson Siqueira

<Ce**********@gmail.comwrote in message
news:11**********************@79g2000cws.googlegro ups.com...
>I am developing a stock market simulator using data from Yahoo's
Finance page. I am using a web browser control hosted on a form that
has a public method named GetPage(), which takes a URL. I want
GetPage() to call m_browser.Navigate() and then wait for the
DocumentComplete event. The DocumentComplete event handler will store
the inner text of the body of the returned document and then wake up
GetPage(), which will then return the text to its caller.

I thought I could use a ManualResetEvent object named m_dataReceived to

manage this. After Navigate(), I call m_dataReceived.Reset() and then
m_dataReceived.WaitOne(). In the DocumentComplete event handler, I
call m_dataReceived.Set(). However, the event handler never runs. If
I take out the events and just let things happen when they want to, I
get the data from the web page.
What am I doing wrong?
Thank you very much.
Rob Richardson

Dec 19 '06 #3
Robson,

That looks great! I'm glad there's an easier way than I was trying!

Thank you very much!

Rob

Dec 19 '06 #4

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

Similar topics

4
by: Jason . | last post by:
I have seen a few articles with a javascript example but it is not working for me. The server side code is processed first and then the javascript so I basically get my page loading splash screen...
3
by: Danny Masti | last post by:
Hello, I have a HIDDEN div with a "Please Wait Message". OnSubmit I show the hidden div with the "Please Wait Message". It works fine. But if I replace the "Please Wait Message" with an animated...
4
by: GTi | last post by:
Hello... I have a page located in a frame. This page contains a form. When the user submit this form I want to popup a "Please Wait" window popup window The post may take some time for the...
4
by: Dennis M. Marks | last post by:
I have multiple functions that dynamically build parts of a page. It can take 15-30 seconds for this process to complete. In IE nothing appears until the page is complete. In Netscape parts of the...
3
by: Lucas Tam | last post by:
Does anyone have easy to use sample code to build a "Please wait... processing data screen?" I'm interested in something like Expedia's search page Thanks. -- Lucas Tam...
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...
2
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
4
by: PinellasBoy | last post by:
I have an stored procedure which takes long time to execute. So I am trying to execute the procedure in another thread by using the thread start function. After the SP starts processing I want to...
4
by: puja patel | last post by:
hi all, I am developing a shopping cart website in C# where after selecting item, user enters credit card details and click on submit button.This request is then processed by the gateway which...
5
by: Jeremy | last post by:
Hi all, I have database actions that will potentially take several seconds to complete. My normal page uses AJAX so keeping the user informed of what is happening is not a problem. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.