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

  • Home
  • SEARCH
  • 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 3353108
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:06:41+00:00 2026-05-18T02:06:41+00:00

I am trying to code a multithreaded WebBrowser application. The WebBrowser elements will just

  • 0

I am trying to code a multithreaded WebBrowser application.

  • The WebBrowser elements will just navigate to a given URL,
  • wait until it loads and then
    • click a button or
    • submit the form.
  • This should happen in a loop forever.

I’m using Microsoft Visual Studio 2010 and Windows Forms

Here’s my code:

//added windows form 30 webbrowser object 
//and now assigning them to an webbrowser array

wbList[0] = webBrowser1; wbList[1] = webBrowser2; wbList[2] = webBrowser3; 
wbList[3] = webBrowser4; wbList[4] = webBrowser5; wbList[5] = webBrowser6; 
wbList[6] = webBrowser7; wbList[7] = webBrowser8; wbList[8] = webBrowser9;
//etc. until:
wbList[29] = webBrowser30;

for (int i = 0; i < 30; i++)
{
    wbList[i].ScriptErrorsSuppressed = true;
    wbList[i].NewWindow += new CancelEventHandler(wb_NewWindow);
}

//********************************** creating threads here

Thread[] AllThread = new Thread[100];

int irWhichWbb = 0;
for (int nn = irDirectPostCount; nn < irNumber+1; nn++)
{
    AllThread[nn] = new Thread(new 
                          ParameterizedThreadStart(this.MultiThreadWebBrowser));
    AllThread[nn].Start(nn.ToString() + ";" + irWhichWbb.ToString());
    irWhichWbb++;
}

Application.DoEvents();
for (int nn = 0; nn < irNumber+1; nn++)
{ AllThread[nn].Join(); }

//Multi thread function
void MultiThreadWebBrowser(object parameter)
{
    string srParam = parameter.ToString();

    int i = Convert.ToInt32 (srParam.Substring(0,(srParam.IndexOf(";"))));
    int irWhichWb = Convert.ToInt32(srParam.Substring(srParam.IndexOf(";")+1));

    string hdrs = "Referer: http://www.xxxxxxxxx.com/xxxxxxxxxx.aspx";

    try
    {
        wbList[irWhichWb].Navigate(srVotingList[i, 0], "_self", null, hdrs);
    }
    catch { }

    try { waitTillLoad(irWhichWb); }
    catch { }
    waitTillLoad3();
}

// wait until webbrowser navigate url loaded
private void waitTillLoad(int irWhichLoad)
{
    WebBrowserReadyState loadStatus;
    //wait till beginning of loading next page  
    int waittime = 100000;
    int counter = 0;
    while (true)
    {
        try
        {
            loadStatus = wbList[irWhichLoad].ReadyState;
            Application.DoEvents();

            if ((counter > waittime) || 
                (loadStatus == WebBrowserReadyState.Uninitialized) || 
                (loadStatus == WebBrowserReadyState.Loading) || 
                (loadStatus == WebBrowserReadyState.Interactive))
            {
                    break;
            }
            counter++;
        }
        catch { }
    }

    //wait till the page get loaded.
    counter = 0;
    while (true)
    {
        try
        {
            loadStatus = wbList[irWhichLoad].ReadyState;
            Application.DoEvents();
            if (loadStatus == WebBrowserReadyState.Complete)
            {
                break;
            }
            if (counter > 10000000)
                break;
            counter++;
        }
        catch { }
    }
}

private void waitTillLoad3()
{
    DateTime dtStart = DateTime.Now;
    while (true)
    {
        if ((DateTime.Now - dtStart).TotalMilliseconds > 4000)
            break;

        Application.DoEvents();
    }
}
  • 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-18T02:06:42+00:00Added an answer on May 18, 2026 at 2:06 am

    You don’t say what kind of failure you get: “doesn’t work” is not a good description.

    I would first try with just a single thread. Does that work?

    You have empty catch blocks, so you are silently ignoring some error conditions. This may well by hiding a problem.

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

Sidebar

Related Questions

Here is the code I'm using to create my multithreaded httpclient object. I'm trying
Im trying to code my own DSL for file manipulation, just for the sake
I was just trying to code the following extension method: using System; using System.Collections.Generic;
I am trying to code TDD style in PHP and one of my biggest
I am trying to code a flowchart generator for a language using Ruby. I
I've been trying to code a Perl script to substitute some text on all
I'm trying to code what I think is a fairly routine AJAX pattern using
I was trying to code along with the PDC2008 Intro to F# video .
I'm trying to code the following HQL query using the Criteria API: var userList
I am currently trying to code my own JS drag and drop script (out

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.