private static int _position;\r
private static string _lastMode;\r
private static string _currentMode;\r
+ private Thread monitor;\r
+ private Boolean kilLThread;\r
\r
public frmActivityWindow()\r
{\r
private void NewActivityWindow_Load(object sender, EventArgs e)\r
{\r
SetScanMode();\r
- Thread monitor = new Thread(LogMonitor);\r
+ monitor = new Thread(LogMonitor);\r
+ _position = 0;\r
+ kilLThread = false;\r
\r
try\r
{\r
{\r
while (true)\r
{\r
+ if (!IsHandleCreated || kilLThread) // break out the thread if the window has been disposed.\r
+ break;\r
+\r
// Perform a reset if require.\r
// If we have switched to a different log file, we want to start from the beginning.\r
if (SetLogFile != _lastMode)\r
break;\r
}\r
\r
- Thread.Sleep(1000);\r
+ Thread.Sleep(750);\r
}\r
}\r
private StringBuilder ReadFile(string file)\r
{\r
MessageBox.Show("PrintLogHeader(): Exception: \n" + exc);\r
}\r
- \r
+\r
}\r
\r
#region Public\r
\r
protected override void OnClosing(CancelEventArgs e)\r
{\r
+ kilLThread = true;\r
+ monitor.Join();\r
e.Cancel = true;\r
- this.Hide();\r
+ this.Dispose();\r
base.OnClosing(e);\r
}\r
}\r
}\r
private void btn_ActivityWindow_Click(object sender, EventArgs e)\r
{\r
- if (ActivityWindow == null)\r
+ if (ActivityWindow == null || !ActivityWindow.IsHandleCreated)\r
ActivityWindow = new frmActivityWindow();\r
\r
if (encodeQueue.isEncoding)\r