Link to home
Start Free TrialLog in
Avatar of amornement
amornement

asked on

Multithreading in an ActiveX control

I have a implemented a worker thread spawned from an MFC control for use in VB.  The thread executes fine but when I attempt to fire an event in the control (passing a string as a parameter) from the thread VB dies with a memory exception error as soon as it attempts to read the event parameter.  How does one fire events in controls safely accross thread boundaries?

The documentation mentions CoMarshalInterThreadInterfaceInStream for this sort of thing (?) but this requires an interface pointer.  If this is the right approach, how do I get this pointer given that it is a windowless control (ie CWnd::GetControlUnknown returns NULL)
Avatar of Belgarat
Belgarat

Does the code tat fires the event run on the same thread as code of normal methods  of your ActiveX control executes (== is your event fired from within a method of the control or from within a complete different thread) ?

ASKER CERTIFIED SOLUTION
Avatar of Liu
Liu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amornement

ASKER

At the risk of sounding stupid, how do I notify a control that doesn't have a window handle associated with it to fire an event/method?  How do I get the control to respond to the notification?

Also, as I mentioned, CoMarshalInterThreadInterfaceInStream seems to be the starting point for doing this sort of thing automatically without having to post messages all over the place.  Where do I get the parameters to pass to it?  At the moment it returns INVALID_PARAM or something along those lines.

Help!