ActiveX and Threads

Posted on 2011-05-06
Last Modified: 2012-05-11
I have an ActiveX control that I create in a Worker Thread.

Had expected the Worker Thread to handle the events from that ActiveX control, but I can only get the Main Thread to handle them.

I want the handling and processing of the ActiveX control events to all be done in the Worker Thread to keep the UI from freezing.


Question by:cgraham2
    1 Comment
    LVL 13

    Accepted Solution

    UIs are touchy when it comes to background threads.  You can only edit the UI in the main thread.  I suggest you trap the events in the main thread and kick off their handling using a background worker if they are long processes.

    Here is an example of how to set one up

    Another less desired method is the old System.Window.Forms.Application.DoEvents() at strategic places in your long process to keep the UI responsive.  It is old school but there is no complexity or weirdness when you use it.


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now