Just assigning the bitmap to another variable does not create a copy, try creating a copy explicitly using the Clone method. Maybe it will help.
Bitmap and threads
Hi All,
Can anyone shed any light on whats going on here?
I have a windows form, which loads a bitmap stored in:
Bitmap bOriginalImage;
I then create a clost
Bitmap backBuffer = bOriginalImage();
this backbuffer is then used in the paint method to display the image in a panel on the form.
I then want to do some analysis on the original file in another thread, as such:
ThreadStart starter = delegate { da.analyse(bOriginalImage); };
Thread t = new Thread(starter);
During the analysis (which takes a few minutes) everything is fine, until something happens to cause the panel to be repainted.
Then I get a runtime error:
System.InvalidOperationException was unhandled
Message="Bitmap region is already locked."
I don't know why, because I assumed that the painting and the analysis were being done on separate copies of the bitmap.
What am I missing?!
Thanks