using System.Windows.Forms;\r
using System.IO;\r
using System.Threading;\r
-using Handbrake.EncodeQueue;\r
using Handbrake.Functions;\r
using Microsoft.Win32;\r
\r
private static int _position;\r
private static string _lastMode;\r
private static string _currentMode;\r
- private Thread monitor;\r
- private Boolean kilLThread;\r
+ private Thread _monitor;\r
+ private Boolean _kilLThread;\r
\r
- public frmActivityWindow()\r
+ public frmActivityWindow(string mode)\r
{\r
+ _kilLThread = false;\r
+ _position = 0;\r
+ if (mode == "scan")\r
+ SetScanMode();\r
+ else\r
+ SetEncodeMode();\r
+\r
InitializeComponent();\r
}\r
private void NewActivityWindow_Load(object sender, EventArgs e)\r
{\r
- SetScanMode();\r
- monitor = new Thread(LogMonitor);\r
- _position = 0;\r
- kilLThread = false;\r
-\r
+ _monitor = new Thread(LogMonitor);\r
+ \r
try\r
{\r
- monitor.Start();\r
+ _monitor.Start();\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show(exc.ToString());\r
+ MessageBox.Show("Unable to monitor HandBrakes log files. Please report this error. If the problem presists, try rebooting your computer.\n\n Debug Informaton:\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
\r
{\r
while (true)\r
{\r
- if (!IsHandleCreated || kilLThread) // break out the thread if the window has been disposed.\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
- {\r
- _position = 0;\r
- ClearWindowText();\r
- PrintLogHeader();\r
- }\r
+ Reset();\r
\r
// Perform the window update\r
switch (SetLogFile)\r
break;\r
}\r
\r
- Thread.Sleep(750);\r
+ try\r
+ {\r
+ Thread.Sleep(1000);\r
+ }\r
+ catch (ThreadInterruptedException)\r
+ {\r
+ // Do Nothnig.\r
+ }\r
+\r
}\r
}\r
private StringBuilder ReadFile(string file)\r
}\r
catch (Exception exc)\r
{\r
- appendText.AppendFormat("\nERROR: The Log file could not be read. You may need to restart HandBrake! " + exc);\r
+ appendText.AppendFormat("\n The Log file could not be read. You may need to restart HandBrake! " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
_position = 0;\r
ClearWindowText();\r
}\r
else\r
rtf_actLog.AppendText(text.ToString());\r
}\r
+ } catch(ThreadInterruptedException)\r
+ {\r
+ // Do Nothing\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show("SetWindowText(): Exception: \n" + exc);\r
+ MessageBox.Show("Unless you are having problems, you can probably ignore this error. It would not hurt to report this error!\n\nSetWindowText(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
}\r
}\r
private void ClearWindowText()\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show("ClearWindowText(): Exception: \n" + exc);\r
+ MessageBox.Show("Unless you are having problems, you can probably ignore this error. It would not hurt to report this error!\n\nClearWindowText(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
}\r
}\r
- public void PrintLogHeader()\r
+ private void PrintLogHeader()\r
{\r
try\r
{\r
}\r
catch (Exception exc)\r
{\r
- MessageBox.Show("PrintLogHeader(): Exception: \n" + exc);\r
+ MessageBox.Show("Unless you are having problems, you can probably ignore this error. It would not hurt to report this error!\n\nPrintLogHeader(): Exception: \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
}\r
\r
}\r
+ private void Reset()\r
+ {\r
+ _position = 0;\r
+ ClearWindowText();\r
+ PrintLogHeader();\r
+ }\r
\r
#region Public\r
\r
}\r
public void SetScanMode()\r
{\r
+ Reset();\r
SetLogFile = "last_scan_log.txt";\r
this.Text = "Activity Window (Scan Log)";\r
}\r
public void SetEncodeMode()\r
{\r
+ Reset();\r
SetLogFile = "last_encode_log.txt";\r
this.Text = "Activity Window (Enocde Log)";\r
}\r
\r
protected override void OnClosing(CancelEventArgs e)\r
{\r
- kilLThread = true;\r
- monitor.Join();\r
+ _kilLThread = true;\r
+ _monitor.Interrupt();\r
+ _monitor.Join();\r
e.Cancel = true;\r
this.Dispose();\r
base.OnClosing(e);\r