Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1025607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:57:12+00:00 2026-05-16T11:57:12+00:00

I have a win forms application that contains a Web Browser control. I need

  • 0

I have a win forms application that contains a Web Browser control. I need to be able to add delay between operations on the web-browser due to the asynchronous nature of navigating.

The Document_Complete event is worthless as it does not take into account that a page may contain multiple AJAX requests. The event ofter fires many times.

UPDATE

The AJAX Requests are made when the page is loaded. So the page loads and content in some DIV is fetched via an HTTP request. So the the Document_Complete event is raises when the document first loads and then when each (AJAX) HTTP request returns. No Bueno.

UPDATE2

My application attempts to read HtmlElements from the Webbrowser.Document object. Because the code executes faster than the HTTP Requests return… the document object does not contain all of the html elements.

What I need is some way to delay the call of methods in the main thread. I have tried using a timer:

private void startTimer()
        {
            timer.Interval = 2000;
            timer.Start();
            while (!BrowserIsReady)
            {
                //Wait for timer
            }
        }

This locks up the thread and the tick event never fires. This loops never ends.

I want to run a series of methods like this:

Navagate("http://someurl.com");
//delay
ClickALink();
//delay
Navagate("Http://somewhere.com");
//delay

Can I solve this problem with a timer and the BackgroundWorker? Can someone suggest a possible solution?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:57:13+00:00Added an answer on May 16, 2026 at 11:57 am

    Thanks for all the suggestions. This is the “Delay” solution I came up with last night. It feels like using a steam roller to crack a peanut but I couldn’t find a more ‘elegant’ answer to this particular problem.

    I am spinning off a new worker thread that invokes a method called “AddDelay”. This method will put the worker thread to sleep for some interval of time. My main (UI) thread loops on the Thread.IsAlive condition while allowing the application to receive OS messages if the thread has not completed.

    This seems to do the trick.

     private void Delay()
            {
                DelayTimer dt = new DelayTimer(1);
                Thread thread = new Thread(new ThreadStart(dt.AddDelay));
                thread.Start();
                while (thread.IsAlive)
                {
                    Application.DoEvents();
                }
    
            }
    
    
    
    
    public class DelayTimer
        {
            private int _seconds;
            public DelayTimer(int time)
            {
                _seconds = time;
            }
            public void AddDelay()
            {
               Thread.Sleep(_seconds*1000);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom control - using Win Forms, that contains four TextBoxes, all have
I have an existing application (C#/Win forms). I need to add functionality to the
I have different instances of an [.NET 3.5] C# win forms application that run
I have written a c# win forms application that allows the user to open
I have a user control with a textbox in a win forms application. I
In a C# Winforms (3.5) application I have added a class that contains many
One of our clients has an old WinForms application that contains forms with a
I am developing a C# Win Forms application that needs to be installed on
I am making a Win Forms application to learn more since I don't have
I have a WinForms application that contains a Dataset ds and a DataGridView dgv.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.