A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.0 KiB

// -----------------------------------------------------------------------
// <copyright file="Dispatcher.cs" company="Steven Kirk">
// Copyright 2014 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Threading
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Perspex.Win32.Threading;
public class Dispatcher
{
private static Dispatcher instance = new Dispatcher();
private MainLoop mainLoop = new MainLoop();
private Dispatcher()
{
}
public static Dispatcher UIThread
{
get { return instance; }
}
public void MainLoop(CancellationToken cancellationToken)
{
this.mainLoop.Run(cancellationToken);
}
public Task InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
{
return this.mainLoop.InvokeAsync(action, priority);
}
}
}