From 2d9fb029986e17218272e01ae1c629237e5c204d Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 25 Jul 2007 22:16:29 +0000 Subject: [PATCH] WinGui: - User is prevented from trying to launch more than 1 encode process from frmMain. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@737 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmMain.cs | 50 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index c66cee0b6..f2471baad 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -646,6 +646,7 @@ namespace Handbrake // Encode / Cancel Buttons // Encode Progress Text Handler //--------------------------------------------------- + Functions.CLI process = new Functions.CLI(); private void btn_encode_Click(object sender, EventArgs e) @@ -675,38 +676,39 @@ namespace Handbrake private void procMonitor(object state) { - - hbProc = process.runCli(this, (string)state, true, true, false, true); + // Make sure we are not already encoding and if we are then display an error. + if (hbProc != null) + { + MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); + } + else + { + hbProc = process.runCli(this, (string)state, true, true, false, true); - MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); + MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); - try - { - Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream); - encode.OnEncodeProgress += encode_OnEncodeProgress; - while (!encode.EndOfStream) + try { - encode.ReadLine(); + Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream); + encode.OnEncodeProgress += encode_OnEncodeProgress; + while (!encode.EndOfStream) + { + encode.ReadLine(); + } + + hbProc.WaitForExit(); + process.closeCLI(); + hbProc = null; + } + catch (Exception) + { + // Do nothing } - hbProc.WaitForExit(); - process.closeCLI(); - hbProc = null; + MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } - catch (Exception) - { - // Do Nothing - } - - //TODO: prevent this event from being subscribed more than once - - - MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } - - - private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining) { if (this.InvokeRequired) -- 2.40.0