view Chronosv2/source/Extensions/Windows/DispatcherObjectExtensions.cs @ 21:dfc81f8bb838

working version for sttocks except ui within metrowpf
author adminsh@apollo
date Tue, 20 Mar 2012 15:07:31 +0000
parents 09d18d6e5f40
children
line wrap: on
line source

using System;
using System.Windows.Threading;

namespace Chronos.Extensions.Windows
{
    /// <summary>
    /// Provides a set of commonly used Dispatcher extension methods
    /// </summary>
    public static class DispatcherObjectExtensions
    {
        #region · Extensions ·

        /// <summary>
        /// Executes the specified <see cref="Action "/> at the <see cref="DispatcherPriority.ApplicationIdle"/> priority 
        /// on the thread on which the DispatcherObject is associated with. 
        /// </summary>
        /// <param name="dispatcherObject">The dispatcher object.</param>
        /// <param name="action">The action.</param>
        public static void InvokeAsynchronously(this DispatcherObject dispatcherObject, Action action)
        {
            dispatcherObject.Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
        }

        /// <summary>
        /// Executes the specified <see cref="Action "/> at the <see cref="DispatcherPriority.ApplicationIdle"/> priority 
        /// on the thread on which the DispatcherObject is associated with. 
        /// </summary>
        /// <param name="dispatcherObject">The dispatcher object.</param>
        /// <param name="action">The action.</param>
        public static void InvokeAsynchronouslyInBackground(this DispatcherObject dispatcherObject, Action action)
        {
            dispatcherObject.Dispatcher.BeginInvoke(DispatcherPriority.Background, action);
        }

        /// <summary>
        /// Executes the specified <see cref="Action "/> at the <see cref="DispatcherPriority.ApplicationIdle"/> priority 
        /// on the thread on which the DispatcherObject is associated with. 
        /// </summary>
        /// <param name="dispatcherObject">The dispatcher object.</param>
        /// <param name="action">The action.</param>
        public static void Invoke(this DispatcherObject dispatcherObject, Action action)
        {
            dispatcherObject.Dispatcher.Invoke(action);
        }

        #endregion
    }
}