summaryrefslogtreecommitdiffstats
path: root/win/C#
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-11-28 23:45:51 +0000
committersr55 <[email protected]>2009-11-28 23:45:51 +0000
commit8f4c571f85b17d0de124836426f892c72b1dc3cd (patch)
treec582a70bb710ea647fc14b9688e06c9262a3346b /win/C#
parent115d524e223a0806b26027b5ed508c4d29081ed7 (diff)
WinGui:
- Cleanly close the ActivityWindow so that HandBrake.exe does not remain active after the main application window has been closed. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2990 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r--win/C#/frmActivityWindow.cs17
-rw-r--r--win/C#/frmMain.cs2
2 files changed, 14 insertions, 5 deletions
diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs
index f909abcd1..af7b62107 100644
--- a/win/C#/frmActivityWindow.cs
+++ b/win/C#/frmActivityWindow.cs
@@ -24,6 +24,8 @@ namespace Handbrake
private static int _position;
private static string _lastMode;
private static string _currentMode;
+ private Thread monitor;
+ private Boolean kilLThread;
public frmActivityWindow()
{
@@ -32,7 +34,9 @@ namespace Handbrake
private void NewActivityWindow_Load(object sender, EventArgs e)
{
SetScanMode();
- Thread monitor = new Thread(LogMonitor);
+ monitor = new Thread(LogMonitor);
+ _position = 0;
+ kilLThread = false;
try
{
@@ -48,6 +52,9 @@ namespace Handbrake
{
while (true)
{
+ 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)
@@ -70,7 +77,7 @@ namespace Handbrake
break;
}
- Thread.Sleep(1000);
+ Thread.Sleep(750);
}
}
private StringBuilder ReadFile(string file)
@@ -197,7 +204,7 @@ namespace Handbrake
{
MessageBox.Show("PrintLogHeader(): Exception: \n" + exc);
}
-
+
}
#region Public
@@ -293,8 +300,10 @@ namespace Handbrake
protected override void OnClosing(CancelEventArgs e)
{
+ kilLThread = true;
+ monitor.Join();
e.Cancel = true;
- this.Hide();
+ this.Dispose();
base.OnClosing(e);
}
}
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index d74d8ef08..58ad36061 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -800,7 +800,7 @@ namespace Handbrake
}
private void btn_ActivityWindow_Click(object sender, EventArgs e)
{
- if (ActivityWindow == null)
+ if (ActivityWindow == null || !ActivityWindow.IsHandleCreated)
ActivityWindow = new frmActivityWindow();
if (encodeQueue.isEncoding)