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.


Comments

Popular Posts