diff --git a/src/Perspex.Base/Threading/Dispatcher.cs b/src/Perspex.Base/Threading/Dispatcher.cs
index af6f1d58af..31191d587c 100644
--- a/src/Perspex.Base/Threading/Dispatcher.cs
+++ b/src/Perspex.Base/Threading/Dispatcher.cs
@@ -50,6 +50,14 @@ namespace Perspex.Threading
this.mainLoop.Run(cancellationToken);
}
+ ///
+ /// Runs continuations pushed on the loop.
+ ///
+ public void RunJobs()
+ {
+ this.mainLoop.RunJobs();
+ }
+
///
/// Invokes a method on the dispatcher thread.
///
diff --git a/src/Perspex.Base/Threading/MainLoop.cs b/src/Perspex.Base/Threading/MainLoop.cs
index e7efefacc1..009d331b28 100644
--- a/src/Perspex.Base/Threading/MainLoop.cs
+++ b/src/Perspex.Base/Threading/MainLoop.cs
@@ -42,37 +42,45 @@ namespace Perspex.Win32.Threading
{
while (!cancellationToken.IsCancellationRequested)
{
- Job job = null;
+ RunJobs();
- while (job != null || this.queue.Count > 0)
- {
- if (job == null)
- {
- lock (this.queue)
- {
- job = this.queue.Dequeue();
- }
- }
+ platform.ProcessMessage();
+ }
+ }
- if (job.Priority < DispatcherPriority.Input && platform.HasMessages())
- {
- break;
- }
+ ///
+ /// Runs continuations pushed on the loop.
+ ///
+ public void RunJobs()
+ {
+ Job job = null;
- try
- {
- job.Action();
- job.TaskCompletionSource.SetResult(null);
- }
- catch (Exception e)
+ while (job != null || this.queue.Count > 0)
+ {
+ if (job == null)
+ {
+ lock (this.queue)
{
- job.TaskCompletionSource.SetException(e);
+ job = this.queue.Dequeue();
}
+ }
- job = null;
+ if (job.Priority < DispatcherPriority.Input && platform.HasMessages())
+ {
+ break;
}
- platform.ProcessMessage();
+ try
+ {
+ job.Action();
+ job.TaskCompletionSource.SetResult(null);
+ }
+ catch (Exception e)
+ {
+ job.TaskCompletionSource.SetException(e);
+ }
+
+ job = null;
}
}