Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi

My Windows Forms program exits with the following error:

 

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Drawing.dll

 

Additional information: Object is currently in use elsewhere.

 

My program consists of a tabControl component with two tabs. The first tab has a picture box where I constantly place new images. The second tab has other stuff. Everything works fine when I remain in the first tab and continuously place images in the picture box, but if I switch to the second tab, then back to the first, I get the error stated. There is another thread apart from the UI thread that does the actual placement of images in the picturebox. What is causing the error?

Posted
yes, the worker thread does place the images in the picture box, but not directly; it uses a delegate method to call a setter function in the UI thread to change the image. I had the same error before due to the worker thread changing UI components directly. I added delegates to fix that. This error on the other hand is caused while in the UI thread. any ideas?
Posted
it seems that a method call in the worker thread was causing the exception. I think that method was making a system call internally, which was the source of the exception. Thanks for the hint.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...