I get Bitmap (25 per 1 second) from a camera using imageAvailable envent. I have to show it on a GUI and also procees that Bitmap. So I am using two bitmaps, one for the live and the other for the processing. The problem is I am getting the invalidOperationException (and it saying "Object is in use currently elsewhere") while I am processing "currentFrame2". For live I am uisng "currentFrame", there is nor problem.
currentFrame = (Bitmap)e.ImageBuffer.Bitmap.Clone();
currentFrame2 = currentFrame;
I was looking at
The above links couldn't help.
Please give me a suggesion to overcome this problem.
Thank you
Try:
currentFrame = (Bitmap)e.ImageBuffer.Bitmap.Clone();
currentFrame2 = (Bitmap)e.ImageBuffer.Bitmap.Clone();
The problem is that currentFrame
and currentFrame2
are referencing the same object. By using a copy for the second object reference, you shouldn't get an exception anymore.