I’m working on a realtime imaging system.
UI thread: grabs images from a camera at 14 fps via timer and does some processing/display. Every 2 seconds, 3 images (about 1mb on disk each) are selected by processing to be written to disk. These are put in a shared queue.
Second thread: dequeues images and writes to disk. Has been given ‘Lowest’ priority.
When the second thread is performing the writes, it takes a noticeable chunk of perf away from the UI thread and causes capture to drop below 14 fps. Not acceptable.
What can I do here? I don’t mind if the writes take a longer time and queue up, there’s plenty of RAM and a regular pause to allow the writes to catch up. The critical factor is for the UI thread to have enough juice to work at 14 fps.
To get a serious answer you should use some kind of profiler tool. If you search an stackoverflow or an google, you’ll find plenty of them. Mostly you have to pay for them, but fortunately there also exists some trial versions which you can test to find the problem.
But my wild guess without any profiler is, that the I/O operation on the disk leads to your performance problems. So maybe you can work against it, if you try to use a SparseFile and / or MemoryMappedFiles (i know it is .Net 4, but cause it is just a wrapper against the Win32 Api you can maybe extract the class from there and use it in .Net 2).