Virtu/Library/DispatcherExtensions.cs
Sean Fausett 27a5e3ac89 Add git attributes file.
Normalize text files.
2013-06-18 16:52:34 +12:00

37 lines
1008 B
C#

using System;
using System.Windows.Threading;
namespace Jellyfish.Library
{
public static class DispatcherExtensions
{
public static void Post(this Dispatcher dispatcher, Action action)
{
if (dispatcher == null)
{
throw new ArgumentNullException("dispatcher");
}
if (action == null)
{
throw new ArgumentNullException("action");
}
new DispatcherSynchronizationContext(dispatcher).Post(state => action(), null);
}
public static void Send(this Dispatcher dispatcher, Action action)
{
if (dispatcher == null)
{
throw new ArgumentNullException("dispatcher");
}
if (action == null)
{
throw new ArgumentNullException("action");
}
new DispatcherSynchronizationContext(dispatcher).Send(state => action(), null);
}
}
}