2019-04-23 01:44:12 +03:00
|
|
|
|
using Windows.ApplicationModel.Core;
|
|
|
|
|
using System;
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
2016-04-25 22:57:44 +03:00
|
|
|
|
using Xamarin.Forms.Internals;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
|
|
|
|
|
namespace Xamarin.Forms.Platform.UWP
|
|
|
|
|
{
|
|
|
|
|
internal class WindowsTicker : Ticker
|
|
|
|
|
{
|
2019-04-23 01:44:12 +03:00
|
|
|
|
[ThreadStatic]
|
|
|
|
|
static Ticker s_ticker;
|
|
|
|
|
|
2018-09-28 19:38:22 +03:00
|
|
|
|
protected override void DisableTimer()
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
2018-09-28 19:38:22 +03:00
|
|
|
|
CompositionTarget.Rendering -= RenderingFrameEventHandler;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 19:38:22 +03:00
|
|
|
|
protected override void EnableTimer()
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
2018-09-28 19:38:22 +03:00
|
|
|
|
CompositionTarget.Rendering += RenderingFrameEventHandler;
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 19:38:22 +03:00
|
|
|
|
void RenderingFrameEventHandler(object sender, object args)
|
2016-03-22 23:02:25 +03:00
|
|
|
|
{
|
2018-09-28 19:38:22 +03:00
|
|
|
|
SendSignals();
|
2016-03-22 23:02:25 +03:00
|
|
|
|
}
|
2019-04-23 01:44:12 +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
|
|
|
|
}
|
|
|
|
|
}
|