// -----------------------------------------------------------------------
//
// Copyright 2014 MIT Licence. See licence.md for more information.
//
// -----------------------------------------------------------------------
namespace Perspex.Threading
{
using System;
using System.Reactive.Concurrency;
///
/// A reactive scheduler that uses Perspex's .
///
public class PerspexScheduler : LocalScheduler
{
///
/// The instance of the .
///
public static readonly PerspexScheduler Instance = new PerspexScheduler();
///
/// Initializes a new instance of the class.
///
private PerspexScheduler()
{
}
///
public override IDisposable Schedule(TState state, TimeSpan dueTime, Func action)
{
return DispatcherTimer.Run(
() =>
{
action(this, state);
return false;
},
dueTime);
}
}
}