StartTimer(Action action, long intervalInMilliseconds) { #if !CSHTML5NETSTANDARD object dispatcherTimer = INTERNAL_Simulator.SimulatorProxy.StartDispatcherTimer(action, intervalInMilliseconds); return(dispatcherTimer); #else global::System.Threading.Timer timer = new global::System.Threading.Timer( delegate(object state) { action(); }, null, intervalInMilliseconds, intervalInMilliseconds); return(timer); #endif // global::System.Threading.Timer timer = new global::System.Threading.Timer( // delegate(object state) // { //#if !CSHTML5NETSTANDARD // INTERNAL_Simulator.WebControl.Dispatcher.BeginInvoke((Action)(() => // { //#endif // action(); //#if !CSHTML5NETSTANDARD // })); //#endif // }, // null, // intervalInMilliseconds, // intervalInMilliseconds); // return timer; }
/// <summary> /// Stops the DispatcherTimer. /// </summary> public void Stop() { if (_timer != null) { StopTimer(_timer); _timer = null; } }
/// <summary> /// Starts the DispatcherTimer. /// </summary> public void Start() { if (_timer == null) { long intervalInMilliseconds = (long)_interval.TotalMilliseconds; //(long)(_interval.TotalSeconds * 1000); if (intervalInMilliseconds == 0) { intervalInMilliseconds = 1; // Note: this appears to be the default bahavior of other XAML platforms. } _timer = StartTimer(OnTick, intervalInMilliseconds); } }