|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
.net threadsI'm writing an application that receives video frame from a camera that releases a GotFrame event carrying the image as event argument 25 times per second. I wrote an event handler FrameReceiver hooked to the GotFrame event that has to process the frame. The main problem is that the frame processing rate can be lower than the camera frame rate (depending on the system load) and the camera releases its events on different threads. I would like: 1) That the differnet threads that process the frames do not overlap each other and do mantain the order they are released from the camera 2) If the recevier is busy processing one frame it should dismiss future GotFrame events or (better) enqueue them in a N position FIFO queue to be processed later on. I'm knew with multi thread programming and any help would be appreciate. Regards, Marco Hello, nbencive***@gmail.com!
n> Hi everybody, n> I'm writing an application that receives video frame from a camera that n> releases a GotFrame event carrying the image as event argument 25 times n> per second. n> I wrote an event handler FrameReceiver hooked to the GotFrame event n> that has to process the frame. n> The main problem is that the frame processing rate can be lower than n> the camera frame rate (depending on the system load) and the camera n> releases its events on different threads. You can introduce/develop manager (queue) that will enqueue frame events from Camera. n> I would like: n> 1) That the differnet threads that process the frames do not overlap n> each other and do mantain the order they are released from the camera This can be achieved via queue, threads may finish work in different order, but if requests are queued the order can be preserved. Access to queue must be made thread-safe ( e.g monitor or mutex ) n> 2) If the recevier is busy processing one frame it should dismiss n> future GotFrame events or (better) enqueue them in a N position FIFO n> queue to be processed later on. queue manager can "live" on separate thread and enqueue requests for futher processing, again the access to the queue has to be synchronized ( monitor, event, mutex, etc ) Hi Vadym,
thank you for your hint but I still have a doubt >This can be achieved via queue, threads may finish work in different order, but if requests >are queued the order can be preserved. How can I enque threads so that the order is preserved?>Access to queue must be made thread-safe ( e.g monitor or mutex ) Thank you again for the time you spent answering. regards, Marco Hello, nbencive***@gmail.com!
> How can I enque threads so that the order is preserved? You do not enqueue threads, you store data that threads will process. Hi,
There's a threading pattern named something like "multiple writers single reader". That's what you need to implement. Also, consider this free power threading library from Jeffrey Richter himself: http://www.wintellect.com/MemberOnly/PowerThreading.aspx (you'll need to sign up first, that's quick and free). <nbencive***@gmail.com> wrote in message Show quote news:1148288831.055122.95340@y43g2000cwc.googlegroups.com... > Hi everybody, > I'm writing an application that receives video frame from a camera that > releases a GotFrame event carrying the image as event argument 25 times > per second. > I wrote an event handler FrameReceiver hooked to the GotFrame event > that has to process the frame. > The main problem is that the frame processing rate can be lower than > the camera frame rate (depending on the system load) and the camera > releases its events on different threads. > I would like: > 1) That the differnet threads that process the frames do not overlap > each other and do mantain the order they are released from the camera > 2) If the recevier is busy processing one frame it should dismiss > future GotFrame events or (better) enqueue them in a N position FIFO > queue to be processed later on. > > I'm knew with multi thread programming and any help would be > appreciate. > Regards, > Marco > |
|||||||||||||||||||||||