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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:46:27+00:00 2026-06-08T11:46:27+00:00

I was struggling finding a good title as I already solved my problem. I

  • 0

I was struggling finding a good title as I already solved my problem. I just need an explication of how I solved it … because I am diving into stuff I just discovered today and it may not be clear right now for me.

So in order to resume my problem resolution here is the way I solved my problem, and what I do not understand.

I am designing a WindowsForm application that crawl into websites in order to retrieve some data. I have several different website to crawl in and each are different. The basic way I use is to use WebRequest. However one website forces me to simulate click, so for this specific website i use a WebBrowser control to invoke a specific javascript function.

I decided to get out of the main thread some crawling work as it was really time consuming and freezed my application.

The way I used to do this was a BackgroundWorker per Search method (one for each website). It worked well for every website except the one with the WebBrowser. I was getting an exception : “Unable to get the window handle for the ‘WebBrowser’ control. Windowless ActiveX controls are not supported.”.

I found out on the web that I couldn’t use the WebBrowser control as I was not in the thread where the WebBrowser was constructed. I decided to create a Form wrapping a WebBrowser inside the DoWork method of the BackgroundWorker instead of the original Form, and to call the Navigate() method for this WebBrowser.

It didn’t work either, with the same exception. I found this answer (http://stackoverflow.com/questions/4269800/webbrowser-control-in-a-new-thread) which helped me a lot (I changed a little bit the answer piece of code to get it working as it was question oriented)

So right now :

I click a button, it creates a BackgroundWorker.
Inside the BackgroundWorker, the launchSearch method is called.
Within this launchSearch method, I create a new thread which is doing all the work I need (This thread has been created pretty much in the same way as the solution I linked above), and i set a “hasActiveThread” boolean to true while the thread has not finished working.
When the work is finished, I get the result and release my BackgroundWorker.

What bother me is that i do not really understand why creating a Form inside my BackgroundWorker “DoWork” method was not working properly when trying to navigate to an url. If you could at least help me to understand why the solution has to be that “complicated”, and the reasons behind this, i would be really thanksfull !

Al_th

  • 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-08T11:46:31+00:00Added an answer on June 8, 2026 at 11:46 am

    Your solution wasn’t worked because all new threads running by BackgroundWorked was started without running Message Loop. Any user interaction actions works through Windows Messages mechanism. See http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows and http://msdn.microsoft.com/en-us/library/windows/desktop/ms644928%28v=vs.85%29.aspx for details. Simple creating of Form object doesn’t init message loop. For running it you may call Form.Show or Form.ShowDialog methods, or Application.Run(…) methods. In working example Message Loop was started with Application.Run() method.

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

Sidebar

Related Questions

I am struggling with finding any good examples of coffeescript and pattern matching apart
i'm digging more and more into Zend_Framework, but finding good resources isn't all too
I've been struggling with finding a suitable solution :- I need an regex expression
I've been struggling with this problem just like everyone else and I'm quite sure
Been struggling with this simple selector problem a couple of hours now and must
im struggling with syntax here: hopefully this question is v simple, im just miising
I just started playing with Django today and so far am finding it rather
I'm designing a new system and finding that I am struggling with the structure
I have been struggling with a problem in Google App Engine and Django and
So I have been struggling with finding a decent C# library to use with

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.