Hi,
I'm having trouble with a multi-threaded program crashing on a specific machine when the worker thread is not initialized at when the _FormClosing method of my main form called.
Here is my on _FormClosing method:
On my development machine (Windows XP) and my test machine (Windows 2000) this works without an issue. On the computer I need it to work (Windows 2000) on it throws this error:
And I cannot figure out where the null reference is coming from. The only object a refer to I'm checking for a null reference and I'm pretty sure primitives can't be null C#
I'm having trouble with a multi-threaded program crashing on a specific machine when the worker thread is not initialized at when the _FormClosing method of my main form called.
Here is my on _FormClosing method:
Code:
private void CycleBox_FormClosing(object sender, FormClosingEventArgs e)
{
// Set the boolean flags to stop cycling in worker thread.
// Closing prevent dialogs from opening
closing = true;
// Cycling tells the thread to stop running.
cycling = false;
// If the thread is created and running.
if (workerThread != null && workerThread.IsAlive)
{
// Tell the user we are working on closing.
Log.writeMessage(log, "Finishing Cycle");
// Wait for current cycle to complete.
workerThread.Join();
// Get rid of the dialog to the user.
Log.closeMessage();
}
}
Code:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Cycle_Box.CycleBox.CycleBox_FormClosing(Object sender, FormClosingEventArgs e)
at System.Windows.Forms.Form.OnFormClosing(FormClosingEventArgs e)
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.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)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///c:/WINNT/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Cycle Box
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/Isotemp%20Research/Cycle%20Box/Cycle%20Box.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
ATE
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Program%20Files/Isotemp%20Research/Cycle%20Box/ATE.EXE
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINNT/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Comment