Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Object is currently in use elsewhere!

Object is currently in use elsewhere!

Scheduled Pinned Locked Moved C#
graphicshelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    engsrini
    wrote on last edited by
    #1

    Hi has anyone have any idea about the following error? Message = Object is currently in use elsewhere. , StackTrace = at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size() at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.CommonLayout() at System.Windows.Forms.ButtonInternal.ButtonFlatAdapter.PaintFlatLayout(PaintEventArgs e, Boolean up, Boolean check, Int32 borderSize) at System.Windows.Forms.ButtonInternal.ButtonFlatAdapter.PaintUp(PaintEventArgs e, CheckState state) at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint(PaintEventArgs pevent) at System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent) at EES.ATE.TouchScreenControls.TouchScreenButton.OnPaint(PaintEventArgs pevent) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam Actually I am updating a GUI's Button image in Backgroundworker class, I didn't use Invokerequired property. I suspect that would be the cause of this error. But this error has been captured Application_ThreadException event. Any idea when this error will occur?

    C 1 Reply Last reply
    0
    • E engsrini

      Hi has anyone have any idea about the following error? Message = Object is currently in use elsewhere. , StackTrace = at System.Drawing.Image.get_Width() at System.Drawing.Image.get_Size() at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.CommonLayout() at System.Windows.Forms.ButtonInternal.ButtonFlatAdapter.PaintFlatLayout(PaintEventArgs e, Boolean up, Boolean check, Int32 borderSize) at System.Windows.Forms.ButtonInternal.ButtonFlatAdapter.PaintUp(PaintEventArgs e, CheckState state) at System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint(PaintEventArgs pevent) at System.Windows.Forms.ButtonBase.OnPaint(PaintEventArgs pevent) at EES.ATE.TouchScreenControls.TouchScreenButton.OnPaint(PaintEventArgs pevent) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam Actually I am updating a GUI's Button image in Backgroundworker class, I didn't use Invokerequired property. I suspect that would be the cause of this error. But this error has been captured Application_ThreadException event. Any idea when this error will occur?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      A background thread should never interact with the UI directly. Instead it should tell the main thread to do it.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      E 1 Reply Last reply
      0
      • C Christian Graus

        A background thread should never interact with the UI directly. Instead it should tell the main thread to do it.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        E Offline
        E Offline
        engsrini
        wrote on last edited by
        #3

        Thats correct. But i read this BackgroundWorker class will not have any cross-threading issues. Is it right? also tell me is this error comes because of Cross-threading invalid operation?

        C S 2 Replies Last reply
        0
        • E engsrini

          Thats correct. But i read this BackgroundWorker class will not have any cross-threading issues. Is it right? also tell me is this error comes because of Cross-threading invalid operation?

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          engsrini wrote:

          But i read this BackgroundWorker class will not have any cross-threading issues. Is it right?

          You still have to synchronise the threads regardless of how the thread is wrapped up.


          Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

          1 Reply Last reply
          0
          • E engsrini

            Thats correct. But i read this BackgroundWorker class will not have any cross-threading issues. Is it right? also tell me is this error comes because of Cross-threading invalid operation?

            S Offline
            S Offline
            Scott Dorman
            wrote on last edited by
            #5

            The BackgroundWorker will not allow any cross-thread operations and will throw an exception if you try to do so. You still need to have a basic understanding of how threading works even when using the BackgroundWorker. If you are trying to change the button image as the result of either progress or completion, you need to do so using either the ProgressChanged or RunWorkerCompleted events. (If you use ProgressChanged, make sure to set the WorkerReportsProgress property to true. See http://msdn2.microsoft.com/en-us/library/system.componentmodel.backgroundworker(vs.80).aspx[^] for more details.

            ----------------------------- In just two days, tomorrow will be yesterday.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups