Balti2016 / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

AsyncVideoSource thread hangs when stopping. #370

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
From visual studio:
1. Connect to USB web cam as VideoCaptureDevice instance
2. Create AsyncVideoSource instance with previous VCD instance
3. Start AsyncVideoSource
4. Call AsyncVideoSource.SignalToStop()
5. Exit program

What is the expected output? What do you see instead?
Expected to see VCD thread stop and AVS thread stop.  Program doesn't exit as a 
thread is blocked on System.Threading.WaitOne.

What version of the product are you using?
AForge.Net 2.2.5

Please provide any additional information below.

AsyncVideoSource.SignalToStop calls IVideoSource.SignalToStop but it doesn't 
cause it's own thread to stop by calling the internal "Free" method.  This 
causes "imageProcessingThread_Worker" to block on isNewFrameAvailable.WaitOne.

Original issue reported on code.google.com by Mark.Lea...@gmail.com on 19 Nov 2013 at 6:22

GoogleCodeExporter commented 9 years ago
Fixed AsyncVideoSource so it disposes internal resources when it was signalled 
to stop. Freeing is done right after nested video source is signalled to stop. 
When freeing the async source un-subscribes from nested source event, so it 
will no longer be notified of new frames, which means freeing internal 
processing thread is safe (especially after waiting till it finishes current 
job).

Committed in revision 1726.

Original comment by andrew.k...@gmail.com on 6 Jan 2014 at 3:23