maui-linux/Xamarin.Forms.Platform.UAP/WindowsTicker.cs

45 строки
936 B
C#
Исходник Обычный вид История

using Windows.ApplicationModel.Core;
using System;
using Windows.UI.Xaml.Media;
using Xamarin.Forms.Internals;
2016-03-22 23:02:25 +03:00
namespace Xamarin.Forms.Platform.UWP
{
internal class WindowsTicker : Ticker
{
[ThreadStatic]
static Ticker s_ticker;
protected override void DisableTimer()
2016-03-22 23:02:25 +03:00
{
CompositionTarget.Rendering -= RenderingFrameEventHandler;
2016-03-22 23:02:25 +03:00
}
protected override void EnableTimer()
2016-03-22 23:02:25 +03:00
{
CompositionTarget.Rendering += RenderingFrameEventHandler;
2016-03-22 23:02:25 +03:00
}
void RenderingFrameEventHandler(object sender, object args)
2016-03-22 23:02:25 +03:00
{
SendSignals();
2016-03-22 23:02:25 +03:00
}
protected override Ticker GetTickerInstance()
{
if (CoreApplication.Views.Count > 1)
{
// We've got multiple windows open, we'll need to use the local ThreadStatic Ticker instead of the
// singleton in the base class
if (s_ticker == null)
{
s_ticker = new WindowsTicker();
}
return s_ticker;
}
return base.GetTickerInstance();
}
2016-03-22 23:02:25 +03:00
}
}