using System;
using System.Windows;
using System.Windows.Threading;

namespace ChatController.Utilities.Extensions
{
    public static class ControlExtensions
    {
        private static readonly Action _EmptyDelegate = delegate { };

        public static void Dispatch(this DispatcherObject p, Action action)
        {
            p.Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
        }

        public static void RefreshUI(this UIElement uiElement)
        {
            uiElement.Dispatcher.Invoke(DispatcherPriority.Render, _EmptyDelegate);
        }
    }
}
