1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace System.Activities.Presentation
10 using System.Threading;
11 using System.Windows.Threading;
13 internal class TaskDispatcher
15 // We need to keep a reference to the WPF Dispatcher so that we can dispatch work to the UI Thread.
16 private Dispatcher dispatcher;
18 // This constructor must be executed on the UI thread.
19 internal TaskDispatcher()
21 this.dispatcher = Dispatcher.CurrentDispatcher;
24 internal virtual void DispatchWorkOnUIThread(DispatcherPriority priority, Delegate method)
26 this.dispatcher.BeginInvoke(priority, method);
29 internal virtual void DispatchWorkOnBackgroundThread(WaitCallback work, object state)
31 ThreadPool.QueueUserWorkItem(work, state);