views:

23

answers:

1

I have a third party ActiveX that represents a video camera. (AcxCamera myCam;)

I connect this camera to a videostream via the Connect method. (myCam.Connect(url);)

It's to note that AcxCamera is an object inherited from the third party Acx, so I can "control" the Connect method.

Now, I have some cameras that should be started synchronously.

I'd like to could do something like:

foreach(AcxCamera cam in myCams)
    cam.BeginConnect();

is it possible?

+1  A: 

When dealing with an ActiveX control it is almost certain that you are dealing with a COM object under the hood which lives in an STA apartment. This means the control is bound to a particular thread, in this case the UI. If you attempt to call methods on it from a background thread the CLR and COM will conspire to make the call actually occur on the thread to which the control has affinity.

In short, it's very unlikely you can achieve what you're looking to do even with some fancy threading logic.

JaredPar
as I understood if you don't tell COM that an object is thread-safe, COM won't allow more than one call at a time to reach the object. Tell COM that the object is thread-safe, however, and it will happily allow the object to field concurrent method calls on multiple threads.
serhio