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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:27:28+00:00 2026-05-11T14:27:28+00:00

I have an IE BHO that’s in development in C#. It is supposed to

  • 0

I have an IE BHO that’s in development in C#. It is supposed to wait for the user to do some stuff, contact our server and download some data, and then alter the DOM of the currently loaded web page with the results.

I am running into some seemingly insurmountable issues relating to the rules of COM compartmentalization and threading — namely, I can’t seem access the IE DOMDocument outside of the current thread and I can’t think of any way to run something asynchronously without locking up IE until it’s finished.

My first attempt had the background server-communication stuff do its thing in an event-driven fashion: my program would initiate communications from within an mshtml event (BeforeNaviagate2 or DocumentComplete, for example), and would post the results from within a separate event handler fired by the server communication object when it finished its work.

That techniqued worked fine in a quick simulator I cobbled together (just a simple app with a WebBrowser control) but in IE it would throw a COM exception because I was attempting to alter page DOM through a separate thread.

So I tried keeping everything in the same function, and having my code wait for the server communications object to do its work with a while loop, like this:

     int waited = 0;     while (!OurServerCommRequest.ready) {         System.Threading.Thread.Sleep(1);         Application.DoEvents();         waited++;          if (waited > constants.TIMEOUT_OURSERVER_REQUEST) {             log.wL('Timed out');         }      }  

The problem with this approach is while the code stays in the original thread, it executes synchroniously with the IE process it fired in (in IE8, it’s one process per tab — like Google Chrome — it seems) … therefore locking up the IE interface until my server communications completes.

Initially I wanted to start processing as soon as the URL was available (via NavigationComplete2 event) but I discovered that waiting for the <body> tag to become available should my server communications finish before the user’s page loaded would also lock up IE — throwing it into an infinite loop while my code waits for the HTML body, while the page is prevented from updating itself do to the aforementioned loop.

I’ve thought about moving all this into the actual user’s page javascript but it seems that by doing so I am opening up a can of worms in wrangling with XSS security issues.

So… my question is such: is it possible to run code asynchroniously in an C# IE BHO while still being able to manipulate the user’s page DOM? I’ve asked around some friends and most people tell me that it is not likely. I’m still new at COM and C#, having come from C/VB.net/JS/AS.

Thank you!

-Tom

  • 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. 2026-05-11T14:27:28+00:00Added an answer on May 11, 2026 at 2:27 pm

    You need to marshal the DOM object from the thread it was created on to your worker thread. Here is a very detailed breakdown of how COM and C# play together.

    All of the IE DOM objects are STA objects.

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

Sidebar

Related Questions

I have a [ComRegisterFunction] that I am using to register a BHO Internet explorer
I have a IE BHO plugin that I only want to be enabled when
I have a browser helper object on IE that have some clipboard history functions.
Have data that has this kind of structure. Will be in ascending order by
Have data that has this kind of structure: $input = [ { animal: 'cat',
I have a C# BHO which sets a hook so that I can track
i have developed an internet explorer toolbar or BHO that i would like to
I have an IE BHO created over 3 years ago that uses IHTMLEventObj::put_keyCode function.
I have an Internet Explorer BHO that can execute a script on the current
I’m writing a BHO (Browser Helper Object) that catches the address the user enters

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.