Could not close winForm

  • Thread starter Thread starter Ayrton Phoenix da silva
  • Start date 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)
 
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.
 
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?
 
That was pertaining to the orignal post, and my reply was of course a joke.
Nothing ?!? about it.
 
Back
Top