Timer/Timed Control While Loop

Posted on 2006-06-07
Last Modified: 2008-03-17
Hello all,

I have been trying to find a solution for this problem for few days now.

I was wondering if someone in here can lead me to a right direction where I can find a way to do a timed/timer controlled while loop.

I have a Microsoft Web Browser object inside a while loop that calls some site on my server to update data remotley. the problem is the while loop is going so much faster than the internet connection, so it wouldnt update all files.

I have looked into Thread.Sleep method, but it freezes everything.

Any help would be greatly appreciated.

Question by:janhoye
    LVL 19

    Assisted Solution

    If I understand it right, you will have the MS Web Browser component and you'd try navigaing to some URL in a Loop so that it updates some data every time

    If yes then instead of the For Loop try using the Navigate_Complete event
    this event is fired when your Web Browser control is done updating the things and is free now, so in there you can write the code to go and update new data or whatever
    LVL 96

    Accepted Solution

    Or use the DocumentComplete event from the web browser control.

    LVL 9

    Expert Comment

    dont forget than you probably need an application.doevents within your loop....

    Author Comment

    thank you so much.

    now, i read enough about NavigateComplete and DocumentComplete.

    but i have another challenge. Is there any possible way to have the have a property like navigatecomplete for the webbrowser control?

    Appreciate the help!
    LVL 96

    Expert Comment

    by:Bob Learned
    Pseudo code for my suggestion:

    Put all the URLs into a queue object

    DocumentComplete handler:

       Process the current HTML document
       If more URLs
          Navigate to the next URL from the queue


    Author Comment

    Thank you both for the answer.

    TheLearnedOne, the solution you gave me at the end actually worked like a charm.

    I queued all the URLs into an array and loop through the array under the DocumentComplete event...

    very very relieved now :)

    thanks again,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now