I’ve got a worker thread which is generating images at ~30/second (Much like capturing a webcam).
I want to perform some processing on these images (Analyse the difference between each sequential one). At present, the thread is raising an event every time an image is ready. This works and seems to be okay but also feels a little flakey – there’s no guarantee that the images will be processed in the correct order (or, assuming the processing takes too long, that processing won’t begin in parallel and thus result in missing / mis-matched pairs of images).
What’s the correct way to pass a sequential stream of images between threads?
One option is a BlockingCollection.
I use this for some parsing then insert into DB where there inserts need to be in the original order.
BlockingCollection(Of T) Class