I've written an ActiveX-Control with a bindable property.
The ActiveX consists of a single Dialog that shows a WinForms UserControl (via CWinFormsControl<..>).
When the ActiveX property changes, a function on the Usercontrol is called which then should do some database calls and display the results.
So far everything works.
Now when I want to move the database queries to a BackgroundWorker, but everytime I call my database functions in the backgroundworker, the ActiveX-Control crashes. The UserControl on it's own (in a normal WinForms-Application) is running fine.
Any idea how I can find what's wrong here? Are there general pitfalls with Threads and ActiveX-Controls I'm not aware of?
ActiveX control is thread-affinity, only the thread(usually is main windows thread) which create the ActiveX control can call into the control's property setting/function call. Otherwise, the control will crash. If the background worker thread want to notify or call back to control, the best way is post windows message to control, and let control's creating thread to reponse to message and do what ever you want to do.