I wrote a program that does some processing on an image delivered via a web cam. There is an event that fires whenever a new frame is received from the camera. However, this happens more frequently than I’d like – so frequently that my image processing function doesn’t complete before a new event appears and calls the same function again.
How can I control when the event fires? Can I execute my image processing, say, every 5 events instead? I believe I have the pseudo code figured out, but I would prefer to see some examples in C#.
Place the event callback “guarded” as follows. Then it won’t be doing the processing many times at the same time.
EDIT : Thread safe if using f.i. Semaphore.