My program is written in C# and manipulates with bitmaps on low level. Everything works fine, but sometimes (very rarely, but stable) exception “Generic GDI+ exception” occurs, and it is very hard to reproduce such situations.
Exception happens on functions LockBits() and UnLockBits(). It contains error code “-2147467259”. On the language of GDI+ it would be method GdipBitmapLockBits and return code 7 or 1.
What kind of reasons may cause such situations?
Any answers greatly appreciate.
I’ve investigated this problem and it seems that it might be connected with threads.
I don’t know for sure what really causes that issues and have no proofs, but after setting up locks throughout the code the problem seems to have gone.