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 8515747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:13:59+00:00 2026-06-11T05:13:59+00:00

I want to do something after the document have completely load… I dont want

  • 0

I want to do something after the document have completely load… I dont want to use WebBrowser.DocumentCompleted Event, so please don’t suggest me this.

I tried 2 ways to do it but they not work. Can someone tell me what I doing wrong?

Example 1

wb.Navigate("http://www.google.com");
while(wb.ReadyState != WebBrowserReadyState.Complete) { }
richtextdocument.Text = wb.DocumentText;

Example 2

wb.Navigate("http://www.google.com");
while(wb.isBusy == true) { }
richtextdocument.Text = wb.DocumentText;
  • 1 1 Answer
  • 0 Views
  • 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-06-11T05:14:00+00:00Added an answer on June 11, 2026 at 5:14 am

    What you are dealing with here is trying to call an inherently asynchronous method synchronously.

    As you mentioned in the comments to your question that the reason for not using DocumentCompleted is that you will need to use that event for other purposes, what I suggest you do is to use the DocumentCompleted event, coupled with a private class boolean flag to determine if this is the special case of DocumentCompleted or not.

    private bool wbNeedsSpecialAction; //when you need to call the special case of Navigate() set this flag to true
    
    public Form1() 
    {
        InitializeComponent();         
        wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
    }
    
    void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        if (wbNeedsSpecialAction)
        {
            richtextdocument.Text = wb.DocumentText;
            wbNeedsSpecialAction = false;
        }
        else
        {
            //other cases of using DocumentCompleted...
        }
    }
    
    public void Browse()
    {
        wbNeedsSpecialAction = true; //make sure the event is treated differently
        wb.Navigate("http://www.google.com");
    }
    

    This will still allow you to control other cases within the event handler.

    You must take special care to ensure that your user is not able to trigger another call to Navigate() before this ‘special action’ page finishes loading, otherwise it may steal the special case event. One way could be to block the UI until the page finishes loading, e.g.:

    Cursor.Current = Cursors.WaitCursor;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have one callback function after actions are done, I'm trying something
How do I reset my numbers after they count? I want something like an
I want to print something while my button is pressed (not after it is
I have a table with links in the html document and they looks something
I have a contact form i want to use Ajax for. My contact.php script
I want to load picture from web server without refreshing the page. I have
I have an XML document, want to do syntax highlighting. The code uses XPathDocument
I have a dropdown cell and after clicking on an item I want to
Working with a Lucene index, I have a standard document format that looks something
i have created an xml file from my c# application i want to use

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.