[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / TaskDispatcher.cs
1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //----------------------------------------------------------------
6
7 namespace System.Activities.Presentation
8 {
9     using System;
10     using System.Threading;
11     using System.Windows.Threading;
12
13     internal class TaskDispatcher
14     {
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;
17
18         // This constructor must be executed on the UI thread.
19         internal TaskDispatcher()
20         {
21             this.dispatcher = Dispatcher.CurrentDispatcher;
22         }
23
24         internal virtual void DispatchWorkOnUIThread(DispatcherPriority priority, Delegate method)
25         {
26             this.dispatcher.BeginInvoke(priority, method);
27         }
28
29         internal virtual void DispatchWorkOnBackgroundThread(WaitCallback work, object state)
30         {
31             ThreadPool.QueueUserWorkItem(work, state);
32         }
33     }
34 }