fixing Bitmap "object in use elsewhere" exception

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Arthur

    #1

    fixing Bitmap "object in use elsewhere" exception

    I periodically get an "Object in use elsewhere" exception in my code while
    using Bitmaps. I am curious to find out if I lock on a bitmap, will that
    remove this problem, or will I have to lock on the Bitmap before drawing it
    on a canvas somewhere.

    I find that this error usually happens if I have a bitmap, set it to the
    background of a form or control, and then I continue to use the Bitmap (e.g.
    get the bitmap's size, or extract information from it using Lockbits and
    some unsafe code, etc.) I am just wondering if the OnPaint method of a
    control locks on the bitmap, or if I must override that rougine and lock on
    that bitmap before using it.

    Thanks,

    Richard Arthur


Working...