X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmActivityWindow.cs;h=5f41c799bd50d4fcd7a31ef6d986c90bf888aa7a;hb=a524194964cbed535f17b1b729fec7847539c94e;hp=af7b62107dfae9c9918d075aac1b44e0c3ccb896;hpb=2f1e983ced2c6a59d2098802585534611108a779;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index af7b6210..5f41c799 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -10,7 +10,6 @@ using System.Text; using System.Windows.Forms; using System.IO; using System.Threading; -using Handbrake.EncodeQueue; using Handbrake.Functions; using Microsoft.Win32; @@ -24,27 +23,31 @@ namespace Handbrake private static int _position; private static string _lastMode; private static string _currentMode; - private Thread monitor; - private Boolean kilLThread; + private Thread _monitor; + private Boolean _kilLThread; - public frmActivityWindow() + public frmActivityWindow(string mode) { + _kilLThread = false; + _position = 0; + if (mode == "scan") + SetScanMode(); + else + SetEncodeMode(); + InitializeComponent(); } private void NewActivityWindow_Load(object sender, EventArgs e) { - SetScanMode(); - monitor = new Thread(LogMonitor); - _position = 0; - kilLThread = false; - + _monitor = new Thread(LogMonitor); + try { - monitor.Start(); + _monitor.Start(); } catch (Exception exc) { - MessageBox.Show(exc.ToString()); + 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); } } @@ -52,17 +55,13 @@ namespace Handbrake { while (true) { - if (!IsHandleCreated || kilLThread) // break out the thread if the window has been disposed. + if (!IsHandleCreated || _kilLThread) // break out the thread if the window has been disposed. break; // Perform a reset if require. // If we have switched to a different log file, we want to start from the beginning. if (SetLogFile != _lastMode) - { - _position = 0; - ClearWindowText(); - PrintLogHeader(); - } + Reset(); // Perform the window update switch (SetLogFile) @@ -77,7 +76,15 @@ namespace Handbrake break; } - Thread.Sleep(750); + try + { + Thread.Sleep(1000); + } + catch (ThreadInterruptedException) + { + // Do Nothnig. + } + } } private StringBuilder ReadFile(string file) @@ -128,7 +135,7 @@ namespace Handbrake } catch (Exception exc) { - appendText.AppendFormat("\nERROR: The Log file could not be read. You may need to restart HandBrake! " + exc); + appendText.AppendFormat("\n The Log file could not be read. You may need to restart HandBrake! " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); _position = 0; ClearWindowText(); } @@ -148,10 +155,13 @@ namespace Handbrake else rtf_actLog.AppendText(text.ToString()); } + } catch(ThreadInterruptedException) + { + // Do Nothing } catch (Exception exc) { - MessageBox.Show("SetWindowText(): Exception: \n" + exc); + 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); } } private void ClearWindowText() @@ -171,10 +181,10 @@ namespace Handbrake } catch (Exception exc) { - MessageBox.Show("ClearWindowText(): Exception: \n" + exc); + 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); } } - public void PrintLogHeader() + private void PrintLogHeader() { try { @@ -202,10 +212,16 @@ namespace Handbrake } catch (Exception exc) { - MessageBox.Show("PrintLogHeader(): Exception: \n" + exc); + 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); } } + private void Reset() + { + _position = 0; + ClearWindowText(); + PrintLogHeader(); + } #region Public @@ -216,11 +232,13 @@ namespace Handbrake } public void SetScanMode() { + Reset(); SetLogFile = "last_scan_log.txt"; this.Text = "Activity Window (Scan Log)"; } public void SetEncodeMode() { + Reset(); SetLogFile = "last_encode_log.txt"; this.Text = "Activity Window (Enocde Log)"; } @@ -300,8 +318,9 @@ namespace Handbrake protected override void OnClosing(CancelEventArgs e) { - kilLThread = true; - monitor.Join(); + _kilLThread = true; + _monitor.Interrupt(); + _monitor.Join(); e.Cancel = true; this.Dispose(); base.OnClosing(e);