Sunday, August 29, 2010

C# - Object is currently in use elsewhere

Why can't Microsoft give better description of the exception??

For this message, System.InvalidOperationException: Object is currently in use elsewhere.

Does this message make sense to you by itself? Which object? Where?

When you see this message during Graphics operations, the object may be referring to the Pen or Brush which you are using for drawing. It seems that Graphics operation is not thread safe. The same pen or brush cannot be use when different threads are rendering on different Graphics. Simply, pen and brush cannot be shared across multiple treads.


No comments:

Post a Comment

Windows 7 - STOP 0x0000007B (0xFFFFF880009A97E8 0xFFFFFFFFC0000034 0x0000000000 0x0000000000)

If you encounter STOP 0x0000007B (0xFFFFF880009A97E8 0xFFFFFFFFC0000034 0x0000000000 0x0000000000) blue screen of death. This is very like...