Jo Shields 3c1f479b9d Imported Upstream version 4.0.0~alpha1
Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
2015-04-07 09:35:12 +01:00

35 lines
1.1 KiB
C#

//----------------------------------------------------------------
// <copyright company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//----------------------------------------------------------------
namespace System.Activities.Presentation
{
using System;
using System.Threading;
using System.Windows.Threading;
internal class TaskDispatcher
{
// We need to keep a reference to the WPF Dispatcher so that we can dispatch work to the UI Thread.
private Dispatcher dispatcher;
// This constructor must be executed on the UI thread.
internal TaskDispatcher()
{
this.dispatcher = Dispatcher.CurrentDispatcher;
}
internal virtual void DispatchWorkOnUIThread(DispatcherPriority priority, Delegate method)
{
this.dispatcher.BeginInvoke(priority, method);
}
internal virtual void DispatchWorkOnBackgroundThread(WaitCallback work, object state)
{
ThreadPool.QueueUserWorkItem(work, state);
}
}
}