summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Utilities
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-12-06 21:32:58 +0000
committersr55 <[email protected]>2013-12-06 21:32:58 +0000
commit87737b6fe394bfb86bd277ccbe314bf11cf14374 (patch)
tree9ca43317c63844a799a4b965b3586fa240c7b6a2 /win/CS/HandBrakeWPF/Utilities
parentc828c40cda553c822560cea5c72522812036abda (diff)
WinGui: Some further work in the background on the still preview feature.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5922 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Utilities')
-rw-r--r--win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs b/win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs
new file mode 100644
index 000000000..14d70c691
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Utilities/DelayedActionProcessor.cs
@@ -0,0 +1,73 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="DelayedActionProcessor.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// An Action processor that supports queueing/delayed action processing.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Utilities
+{
+ using System;
+ using System.Timers;
+
+ /// <summary>
+ /// An Action processor that supports queueing/delayed action processing.
+ /// </summary>
+ public class DelayedActionProcessor
+ {
+ /// <summary>
+ /// The task.
+ /// </summary>
+ private Action task;
+
+ /// <summary>
+ /// The timer.
+ /// </summary>
+ private Timer timer;
+
+ /// <summary>
+ /// The set task.
+ /// </summary>
+ /// <param name="taskReset">
+ /// The task reset.
+ /// </param>
+ /// <param name="timems">
+ /// The timems.
+ /// </param>
+ public void PerformTask(Action taskReset, int timems)
+ {
+ if (timer != null)
+ {
+ timer.Stop();
+ timer.Close();
+ }
+
+
+ timer = new Timer(timems) { AutoReset = true };
+ timer.Elapsed += this.timer_Elapsed;
+ task = taskReset;
+ timer.Stop();
+ timer.Start();
+ }
+
+ /// <summary>
+ /// The timer_ elapsed.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void timer_Elapsed(object sender, ElapsedEventArgs e)
+ {
+ if (task != null)
+ {
+ timer.Stop();
+ task();
+ }
+ }
+ }
+}