views:

212

answers:

2

Running into kind of a strange problem:

I'm using delphi 6.0 and trying to integrate a third party activex control which connects to a server, streams and renders video (no visibility into this control).

The control has a frame rate setting from 1 - 30 and if i set this to a small value like 1, the VCL thread seems to block for a second every second.

In other words, it seems that when the video rendering is done inside this ActiveX control, it sleeps for the time until it needs to render the next frame, but this is speculation on my part.

Looking into the registry I see that this control is Apartment threading so i thought that the way this must be happening is that i created the control on the VCL thread and thus the rendering thread within the control is marshalled to run on the VCL thread (doesn't actually make much sense for threads internal to the control to be marshalled does it?) as well and due to some sleep logic it causes the VCL thread to block.

Based on this i figured if i created a dedicated thread to create this control (with a hidden window + a message pump), the sleeps would happen on this ActiveXCreatorThread instead of VCL. The activex control is created using CreateParented(Fowner).

Needless to say this didn't work and the VCL thread continues to block in the same way and i'm puzzled. What do you think is causing the original behavior? and why wouldn't my hack have worked?

Thanks!

+1  A: 

My guess is since this is a control with a user interface that somehow it always executes in the main UI thread. Not sure how that is accomplished with ActiveX but it stands to reason that it would need to happen this way since the UI needs to be updated by one thread.

Not sure that helps much. The only work around I can think of is to run the control in a separate exe.

Kevin Gale
A: 

You may find this article useful: How to debug application’s hang?

Alexander