Initial commit

This commit is contained in:
2014-04-30 16:57:42 -04:00
commit 5c4a1c8b4c
126 changed files with 52769 additions and 0 deletions

36
Helpers/DelayedMethod.cs Normal file
View File

@@ -0,0 +1,36 @@
using System.Timers;
using System.Windows.Threading;
namespace Common.Helpers
{
public class DelayedMethod
{
public delegate void DelayedMethodDelegate();
private readonly Timer _delayTimer;
private readonly DelayedMethodDelegate _methodDelegate;
private readonly Dispatcher _dispatcher;
public DelayedMethod(int interval, DelayedMethodDelegate methodDelegate)
{
_dispatcher = Dispatcher.CurrentDispatcher;
_methodDelegate = methodDelegate;
_delayTimer = new Timer(interval) { AutoReset = false };
_delayTimer.Elapsed += handleDelayTimerElapsed;
}
public void Reset()
{
_delayTimer.Stop();
_delayTimer.Start();
}
private void handleDelayTimerElapsed(object sender, ElapsedEventArgs e)
{
// Make sure we're on the right thread
if (!_dispatcher.CheckAccess())
_dispatcher.Invoke(_methodDelegate);
}
}
}