mirror of
https://github.com/digital-jellyfish/Virtu.git
synced 2024-06-12 01:29:27 +00:00
365e5723c1
--HG-- extra : convert_revision : svn%3Affd33b8c-2492-42e0-bdc5-587b920b7d6d/trunk%4050811
53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
using System;
|
|
using System.Windows.Threading;
|
|
|
|
namespace Jellyfish.Library
|
|
{
|
|
public static class DispatcherExtensions
|
|
{
|
|
public static void CheckBeginInvoke(this Dispatcher dispatcher, Action action)
|
|
{
|
|
if (dispatcher == null)
|
|
{
|
|
throw new ArgumentNullException("dispatcher");
|
|
}
|
|
if (action == null)
|
|
{
|
|
throw new ArgumentNullException("action");
|
|
}
|
|
|
|
if (dispatcher.CheckAccess())
|
|
{
|
|
action();
|
|
}
|
|
else
|
|
{
|
|
dispatcher.BeginInvoke(action);
|
|
}
|
|
}
|
|
|
|
#if WINDOWS
|
|
public static void CheckInvoke(this Dispatcher dispatcher, Action action)
|
|
{
|
|
if (dispatcher == null)
|
|
{
|
|
throw new ArgumentNullException("dispatcher");
|
|
}
|
|
if (action == null)
|
|
{
|
|
throw new ArgumentNullException("action");
|
|
}
|
|
|
|
if (dispatcher.CheckAccess())
|
|
{
|
|
action();
|
|
}
|
|
else
|
|
{
|
|
dispatcher.Invoke(action);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
}
|