annotate MetroWpf/MetroWpf.Framework/TimedDelegates.cs @ 60:fc62c971a117

upload to blog
author Steven Hollidge <stevenhollidge@hotmail.com>
date Sat, 21 Apr 2012 21:19:39 +0100
parents 060f02cd4591
children
rev   line source
15
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
1 using System;
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
2 using System.Diagnostics;
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
3
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
4 namespace MetroWpf.Framework
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
5 {
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
6 public class TimedDelegates
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
7 {
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
8 public static void ExecuteAction(
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
9 Action action,
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
10 out Stopwatch stopwatch)
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
11 {
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
12 stopwatch = new Stopwatch();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
13 stopwatch.Start();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
14 action();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
15 stopwatch.Stop();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
16 }
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
17
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
18 public static void ExecuteAction<T>(
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
19 Action<T> action,
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
20 T paramIn,
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
21 out Stopwatch stopwatch)
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
22 {
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
23 stopwatch = new Stopwatch();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
24 stopwatch.Start();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
25 action(paramIn);
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
26 stopwatch.Stop();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
27 }
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
28
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
29 public static T ExecuteFunc<T>(
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
30 Func<T> func,
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
31 out Stopwatch stopwatch)
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
32 {
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
33 stopwatch = new Stopwatch();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
34 stopwatch.Start();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
35 T result = func();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
36 stopwatch.Stop();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
37 return result;
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
38 }
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
39
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
40 public static T ExecuteFunc<T>(
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
41 Func<T, T> func,
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
42 T paramIn,
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
43 out Stopwatch stopwatch)
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
44 {
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
45 stopwatch = new Stopwatch();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
46 stopwatch.Start();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
47 T result = func(paramIn);
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
48 stopwatch.Stop();
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
49 return result;
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
50 }
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
51 }
060f02cd4591 Initial commit, pre airport work
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
52 }