By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

"Red Cross" - The object is currently in use elsewhere

P: n/a
Hello,

I have a C# Windows Forms application for machine. Due to some unknown
reasons, the application face problems with unexpected exceptions happening,
resulting in two red lines forming a red cross across a certain
control (the entire form, labels and so on). I get the following message in
MessageBox.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: The object is currently in use elsewhere.
at System.Drawing.Graphics.EndContainer(GraphicsConta iner container)
at
System.Windows.Forms.DibGraphicsBufferManager.Rele aseBuffer(GraphicsBuffer
buffer)
at System.Windows.Forms.GraphicsBuffer.Dispose()
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


The machine is used to handle Microchip Test. When running in production, it
will update the output quantity on the Forms. When the "Red Cross" appears,
the application will hang but machine still keep running. All the data that
generate after that will be lost. This issue is very serious. All my customer
complaining on this issue.
Anyone has the solution? Please reply me as soon as possible. Thanks.
Apr 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Mau Kae Horng,

So you use different threads to draw on the control/form at the same time?

--

Stoitcho Goutsev (100)

"Mau Kae Horng" <Mau Kae Ho***@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
Hello,

I have a C# Windows Forms application for machine. Due to some unknown
reasons, the application face problems with unexpected exceptions
happening,
resulting in two red lines forming a red cross across a certain
control (the entire form, labels and so on). I get the following message
in
MessageBox.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidOperationException: The object is currently in use
elsewhere.
at System.Drawing.Graphics.EndContainer(GraphicsConta iner container)
at
System.Windows.Forms.DibGraphicsBufferManager.Rele aseBuffer(GraphicsBuffer
buffer)
at System.Windows.Forms.GraphicsBuffer.Dispose()
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


The machine is used to handle Microchip Test. When running in production,
it
will update the output quantity on the Forms. When the "Red Cross"
appears,
the application will hang but machine still keep running. All the data
that
generate after that will be lost. This issue is very serious. All my
customer
complaining on this issue.
Anyone has the solution? Please reply me as soon as possible. Thanks.

Apr 12 '06 #2

P: n/a
On Wed, 12 Apr 2006 04:01:01 -0700, Mau Kae Horng wrote:
I have a C# Windows Forms application for machine. Due to some unknown
reasons, the application face problems with unexpected exceptions happening,
resulting in two red lines forming a red cross across a certain
control (the entire form, labels and so on). I get the following message in
MessageBox.


You have Red Cross virus.
Apr 12 '06 #3

P: n/a
Actually, I am using multithreading in the application. The threads will set
the Event to let the application to do the data updates on the form. In other
words, the form will updates in every 100ms depending on the event set by
other threads.

Beside, all the control I am using is User Control. I inherit the
System.Windows.Forms.Control to create my own control. I also override
On_Paint() function to draw my own style for the control. Will this affected?


"Stoitcho Goutsev (100)" wrote:
Mau Kae Horng,

So you use different threads to draw on the control/form at the same time?

--

Stoitcho Goutsev (100)


Apr 13 '06 #4

P: n/a
Mau Kae Horng,

All the updates thad you do to the UI has to be done by the UI thread (the
thread that runs the message pump and has created the controls). If you try
to update the UI from a working thread many bad things can happen including
the error that you get. Marshaling the call is done via Control.Invoke or
Control.BeginInvoke methods.

This question has been asked milons of times; just google for Control.Invoke
and Control.InvokeRequired to find out how to do it.
--
HTH
Stoitcho Goutsev (100)

"Mau Kae Horng" <Ma*********@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.com...
Actually, I am using multithreading in the application. The threads will
set
the Event to let the application to do the data updates on the form. In
other
words, the form will updates in every 100ms depending on the event set by
other threads.

Beside, all the control I am using is User Control. I inherit the
System.Windows.Forms.Control to create my own control. I also override
On_Paint() function to draw my own style for the control. Will this
affected?


"Stoitcho Goutsev (100)" wrote:
Mau Kae Horng,

So you use different threads to draw on the control/form at the same
time?

--

Stoitcho Goutsev (100)

Apr 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.