The truth about LockBits



It was mentioned here that LockBits can sometimes be vulnerable to the
GC. Though the implication of docs that I've seen regarding LockBits
would imply that it is immune to the GC, I do have an app where a
custom control seems to lose its buffer and starts displaying random
data. Of course that couldn't be a bug in my code. <g> (it does seem
to wait a while, and it happens at random).

Seriously, has anyone heard of this? Any way to guard against it?



Nicholas Paldino [.NET/C# MVP]


What do you mean by LockBits can be vulnerable to GC? Unless you let go
of the Bitmap reference and the BitmapData instance, I don't see how that's
even remotely possible. On top of that, I can't see a situation where you
would let go of those references until your work was done.

Can you show a piece of code?

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question