ActiveX and Threads

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.

Thoughts?

cgraham2Asked:
Who is Participating?
 
Corey ScheichConnect With a Mentor DeveloperCommented:
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

http://www.java2s.com/Code/VB/GUI/BackgroundWorkerDemo.htm

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.

Regards,
Corey2
0
All Courses

From novice to tech pro — start learning today.