04-30-2009 08:48 AM
Hello,
I'm trying to add a simple overlay on a image using a secondary thread. When I execute the
AxCWIMAQViewer1.Image.Overlays.Item(1).DrawRectangle(m_rectangle, CWIMAQOverlayModes.cwimaqOverlayModePaint,
System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua))
function I have a COMException error. If I run the same function in the main thread (for exemple on the click event of a button) the function work correctly. I attach my simple project and the bitmap of the error.
Thank You for the help.
Gualtiero
05-05-2009 03:24 AM
Hi Gualtiero,
I'm taking care of your issue. Thanks for the example and the attached screenshot; I'll work on it and reply to this thread as soon as possible.
Best regards,
Fabio
05-07-2009 04:11 AM
Hi Gualtiero,
I've found the reason why you're getting this error: you can share the Rectangle object on separate thread siche we don't support multi-thread with our ActiveX control. It is single threaded apartment (STA).
See http://www.codeproject.com/KB/COM/CCOMThread.aspx for a good overview.
Sorry for the delay of the reply,
Best regards,
Fabio
05-07-2009 11:24 AM
Hi Fabio,
Thank You very much for your explanation. Do You think that new releases of the National Vision ActiveX will be support multi thread application?
Gualtiero
05-18-2009 11:10 AM
Another solution for you will be to mashall all the ActiveX calls on the HMI thread ...... you will haev to right plenty of delegates for the HMI thread to execute synchronously when your background thread needs it.
It is a serious disavantage but it works fine 😞
Otherwise, think about going back to C++