Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-06-2009
Member
 
Join Date: Feb 2009
Posts: 56
Object is currently in use elsewhere

hi,

I often receive an InvalidOperationException with the message 'Object is currently in use elsewhere' whenever I try to use brushes or pens over multiple threads. However, there are no problems when I perform the same thing by using fonts. Why is this happening using brushes or pens then.....what is the problem ? please suggest some suitable solutions....
Reply With Quote
  #2  
Old 09-06-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Object is currently in use elsewhere

I would suggest you to clone each object on different threads since using multiple objects on threads will cause multi-threading which is the main root of this exception error, I think...
Reply With Quote
  #3  
Old 09-06-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Object is currently in use elsewhere

I was also getting the same InvalidOperationException when I used to close my forms. My solution was to make sure that all my controls got disposed in the Dispose method of my UserControls. Here's the code :

Code:
protected override void Dispose(bool disposing)
         {
           if (disposing)
           {
             foreach (Control control in this.Controls)
             {
               IDisposable disposable = control as IDisposable;
               if (disposable != null)
               {
                 disposable.Dispose();
               }
             }
             if (components != null)
             components.Dispose();
            }
           base.Dispose(disposing);
         }
Reply With Quote
  #4  
Old 09-06-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Object is currently in use elsewhere

I don't know whether someone has got the perfect solution to this problem yet....I would simply suggest you that - do not use multi-threading....
Reply With Quote
  #5  
Old 09-06-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Object is currently in use elsewhere

This error normally occurs while using automatic double buffering on
.NET version 1.1. It doesn't mean that it doesn't exists on the other versions.

You can handle the exception by perform manual double buffering..
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Object is currently in use elsewhere"
Thread Thread Starter Forum Replies Last Post
Getting HP AIO Device object server register class object failed message on my system Donoho Hardware Peripherals 6 06-06-2011 01:34 AM
Scope of Object or variable in Object oriented Programming Languages Dėfrim Software Development 3 08-01-2011 06:20 AM
Differents between object and static object Sarfaraj Khan Software Development 5 29-01-2010 01:11 PM
Object reference not set to an instance of an object KAIRU26 Software Development 3 05-09-2009 08:14 PM
Object test = new Object() <-- Java, best way in C++ ADISH Software Development 3 25-10-2008 02:32 PM


All times are GMT +5.5. The time now is 07:00 AM.