serhio
serhio

Reputation: 28586

Make an operation asynchronous

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?

Upvotes: 2

Views: 77

Answers (1)

JaredPar
JaredPar

Reputation: 754575

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.

Upvotes: 1

Related Questions