I have a Bitmap that I’m trying to save and I keep getting the “Object is currently in use elsewhere” error. Now I know GDI+ sucks with threading and that I’m supposed to use the lock{} statement but it’s not working. My code is below, what am I doing incorrectly?
Bitmap bitmap = new Bitmap();
lock (bitmap)
{
bitmap.Save([filepath], ImageFormat.Png);
}
You should lock other dummy object:
Not sure if that’s your problem, but that’s the way
lockworks in .Net.