Could not close winForm

  • Thread starter Ayrton Phoenix da silva
  • Start date
A

Ayrton Phoenix da silva

Dear all,

In my winForm, when user select QUIT, and I will use multi threading to save
user information and then close the application. Sometime it will throw
'Object reference not set to an instance of an object.' I'm the following
error fairly often (but randomly), and I can't
figure out why it is happening. Any ideas?

Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmUpdateUIState(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.ParkingWindow.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
 
G

Guest

when you close your form, threads its process created terminate. if you
really need to do something lengthy after the form is closed, do it in a
separate process.
 
H

Herfried K. Wagner [MVP]

Ayrton Phoenix da silva said:
In my winForm, when user select QUIT, and I will use multi threading to
save user information and then close the application. Sometime it will
throw 'Object reference not set to an instance of an object.' I'm the
following error fairly often (but randomly), and I can't
figure out why it is happening. Any ideas?

Are you sure you are not accessing Windows Forms controls'/forms' instance
members directly from within your threads?
 
G

Guest

That was pertaining to the orignal post, and my reply was of course a joke.
Nothing ?!? about it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top