bitmap - How can I lock my object using C# in dll -
i have i/p camera , function repeating , receiving each frame.
public bitmap processframe(bitmap frame) { }
here buffering place buffering last 100 bitmaps:
lock (writer) { bm[now] = new bitmap(frame); = (now == 99) ? 0 : + 1; }
when press record record video, need save every buffered bitmaps , after have save incoming bitmaps received after pressing record. when press record , using code below save buffered bitmaps video file lose of incoming frames. incoming frames while processing section, dropped , don't want drop them.
lock (writer) { (int = now; < 150; i++) { if (bm[i] == null) break; writer.writevideoframe(bm[i]);//adding frame existing open file } if (now != 0) { (int = 0; < - 1; i++) { writer.writevideoframe(bm[i]);//adding frame existing open file } } }
here part incoming frames saved in video file
lock (writer) { writer.writevideoframe(frame);//adding frame existing open file }
i have searched , found lock me. when saving buffered bitmaps lock lock writer bitmap has come stop @ writer , wait unlocked, did not help.
what should do? how can make safe thread? using opensource ispy , think make thread each frame , call thread. me save incoming frame.
instead of using silly fixed array type solution, why not use concurrentqueue? won't have deal threading since that's thread safe class. have 1 thread pulling frames head of queue , writing them , have other thread add.
Comments
Post a Comment