diff MetroWpf/MetroWpf.Framework/TimedDelegates.cs @ 15:060f02cd4591

Initial commit, pre airport work
author stevenh7776 stevenhollidge@hotmail.com
date Mon, 12 Mar 2012 23:05:21 +0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MetroWpf/MetroWpf.Framework/TimedDelegates.cs	Mon Mar 12 23:05:21 2012 +0800
@@ -0,0 +1,52 @@
+using System;
+using System.Diagnostics;
+
+namespace MetroWpf.Framework
+{
+  public class TimedDelegates
+  {
+    public static void ExecuteAction(
+  Action action,
+  out Stopwatch stopwatch)
+    {
+      stopwatch = new Stopwatch();
+      stopwatch.Start();
+      action();
+      stopwatch.Stop();
+    }
+
+    public static void ExecuteAction<T>(
+      Action<T> action,
+      T paramIn,
+      out Stopwatch stopwatch)
+    {
+      stopwatch = new Stopwatch();
+      stopwatch.Start();
+      action(paramIn);
+      stopwatch.Stop();
+    }
+
+    public static T ExecuteFunc<T>(
+      Func<T> func,
+      out Stopwatch stopwatch)
+    {
+      stopwatch = new Stopwatch();
+      stopwatch.Start();
+      T result = func();
+      stopwatch.Stop();
+      return result;
+    }
+
+    public static T ExecuteFunc<T>(
+      Func<T, T> func,
+      T paramIn,
+      out Stopwatch stopwatch)
+    {
+      stopwatch = new Stopwatch();
+      stopwatch.Start();
+      T result = func(paramIn);
+      stopwatch.Stop();
+      return result;
+    }
+  }
+}