diff --git a/src/Avalonia.Base/Threading/Dispatcher.cs b/src/Avalonia.Base/Threading/Dispatcher.cs
index a8ce1b8115..d46b7142f4 100644
--- a/src/Avalonia.Base/Threading/Dispatcher.cs
+++ b/src/Avalonia.Base/Threading/Dispatcher.cs
@@ -15,7 +15,7 @@ namespace Avalonia.Threading
/// In Avalonia, there is usually only a single in the application -
/// the one for the UI thread, retrieved via the property.
///
- public class Dispatcher
+ public class Dispatcher : IDispatcher
{
private readonly JobRunner _jobRunner;
private IPlatformThreadingInterface _platform;
@@ -72,22 +72,13 @@ namespace Avalonia.Threading
_jobRunner?.RunJobs();
}
- ///
- /// Invokes a method on the dispatcher thread.
- ///
- /// The method.
- /// The priority with which to invoke the method.
- /// A task that can be used to track the method's execution.
+ ///
public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
return _jobRunner?.InvokeAsync(action, priority);
}
- ///
- /// Post action that will be invoked on main thread
- ///
- /// The method.
- /// The priority with which to invoke the method.
+ ///
public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
_jobRunner?.Post(action, priority);
diff --git a/src/Avalonia.Base/Threading/IDispatcher.cs b/src/Avalonia.Base/Threading/IDispatcher.cs
new file mode 100644
index 0000000000..6301015a9a
--- /dev/null
+++ b/src/Avalonia.Base/Threading/IDispatcher.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Avalonia.Threading
+{
+ ///
+ /// Dispatches jobs to a thread.
+ ///
+ public interface IDispatcher
+ {
+ ///
+ /// Determines whether the calling thread is the thread associated with this .
+ ///
+ /// True if he calling thread is the thread associated with the dispatched, otherwise false.
+ bool CheckAccess();
+
+ ///
+ /// Throws an exception if the calling thread is not the thread associated with this .
+ ///
+ void VerifyAccess();
+
+ ///
+ /// Invokes a method on the dispatcher thread.
+ ///
+ /// The method.
+ /// The priority with which to invoke the method.
+ /// A task that can be used to track the method's execution.
+ void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal);
+
+ ///
+ /// Post action that will be invoked on main thread
+ ///
+ /// The method.
+ /// The priority with which to invoke the method.
+ // TODO: The naming of this method is confusing: the Async suffix usually means return a task.
+ // Remove this and rename InvokeTaskAsync as InvokeAsync. See #816.
+ Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal);
+ }
+}
\ No newline at end of file