TouchlessMgr.Dispose() hang

Jun 26, 2009 at 10:19 AM

Hi,

When I try to dispose my TouchlessMgr instance, the app is freezing.

It hangs on "        g_pMediaControl->Stop();"  in "CameraMethods::StopCamera()" file "WebcamLib.cpp" line 381

I have revision 31008 of file (latest in svn).

My cam is a Microsoft VX-2000.

I think this can be due to not enough time between a previous dipose and a new instanciation of manager.

 

I have wrapped the lib into an ActiveX to use in a IE webpage.

I will try to search more further.

Jun 26, 2009 at 10:39 AM

Found : Deadlock

 

When calling IMediaControl.Stop(), there can be a deadlock if the UI thread is not responding.

Since I have a live view of the image (handle on Camera.OnImageCaptured event, get image, set picturebox image) and that I have to deal with InvokeRequired property, I have changed sync Invoke() calls to async calls with BeginInvoke(). And that solved my deadlock problem.

Link that helped me to understand : http://www.microsoft.com/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.win32.programmer.directx.video&tid=1d22c916-383a-4f96-80a0-fae8c5d9db2d&cat=&lang=&cr=&sloc=&p=1

Jun 26, 2009 at 1:19 PM

Great work,

I also could observe this deadlock from time to time in a plain win app, but could not explain to me why it happened.
I don't know if the BeginInvoke is ok to do and cleanly resolves the bug, but at least it helps :)

I could only observe the deadlock inside the debugger, but not when executing my app compiled in RELEASE mode and starting it outside the studio.

Coordinator
Jun 30, 2009 at 3:15 AM

Very nice. Is there anything more to it than changing OnImageCaptured.Invoke to OnImageCaptured.BeginInvoke? I'll work this into my next changeset.