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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:47:07+00:00 2026-05-27T01:47:07+00:00

Hello I am working with my web browser and I keep getting the following

  • 0

Hello I am working with my web browser and I keep getting the following error: Cannot access a disposed object.
Object name: ‘WebBrowser’.

What I am trying to do with my code is loop through every item in a listbox, visit a page, make a message box saying success popup, then move down to the next item. What happens is it only says ‘Success’ for the first two items then it stops working for the third and when I close down my program I get the error/warning listed above.

This is my code:

listBox3.SelectedIndex = 0;

for (int i = 0; i < listBox3.Items.Count; i++)
{
     completed();
     move();
}

This is the code for the completed():

webBrowser1.Navigate(listBox3.SelectedItem.ToString());

while (!(webBrowser1.ReadyState == WebBrowserReadyState.Complete))
{
    Application.DoEvents();

    if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
    {
        MessageBox.Show("Success!");
    }
}

This is the code for the move():

listBox3.SelectedIndex = +1;

webBrowser1.Navigate(listBox3.SelectedItem.ToString());

while (!(webBrowser1.ReadyState == WebBrowserReadyState.Complete))
{
    Application.DoEvents();

    if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
    {
        MessageBox.Show("Success!");
    }
}

And I get the error in this line:

if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
     ....
  • 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-05-27T01:47:08+00:00Added an answer on May 27, 2026 at 1:47 am

    You attempt to access webBrowser1, but it’s been disposed of since it’s no longer needed by the form. You can protect against this by checking for webBrowser1.IsDisposed and exiting the loop if it is, after Application.DoEvents(), like so:

    webBrowser1.Navigate(listBox3.SelectedItem.ToString());
    
    DateTime start = DateTime.Now;
    
    while(webBrowser1.ReadyState != WebBrowserReadyState.Complete) {
        Application.DoEvents();
    
        if(webBrowser1.IsDisposed || DateTime.Now.Subtract(start).TotalSeconds > 10.0) break; // A time limit of 10 seconds, can be changed
    
        if(webBrowser1.ReadyState == WebBrowserReadyState.Complete) {
            MessageBox.Show("Success!");
        }
    }
    

    Also, I can’t say for certain since I don’t have the entire code, but… a loop is very inefficient there. It will hog CPU cycles doing nothing. A better solution might be to handle the WebBrowser‘s DocumentCompleted event.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
I've been trying to get a simple hello world web app running on Sinatra.
I'm trying to get a trivial Django project working with Passenger on Dreamhost, following
I'm working on a jsp(test.jsp) in a web-app with a servlet context of /hello.
hello i working following system. windows 7 ultimate sp1 x64. visual studio 9 c++
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello I have this list that i am working on. When i move the
Hello , I am currently working on the student association's website. The student's association
HELLO, I am working on XCODE 3.1.4 , my iphone have 3.1.2 os...But as
hello i have created one windows application in c# .net and its working fine

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.