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

Facebook - Control privacy setting of liked page

By default, Facebook displayed your liked page to public. It is the user responsibility to adjust the privacy setting. And in my opinion, F...