Beispiel #1
0
        protected override IDisposable StartCore(Action <TimeSpan> tick)
        {
            EnsureTimerQueueCreated();
            var msPerFrame = 1000 / FramesPerSecond;

            timerDelegate = (_, __) => tick(TimeSpan.FromMilliseconds(Environment.TickCount));

            UnmanagedMethods.CreateTimerQueueTimer(
                out var timer,
                _timerQueue,
                timerDelegate,
                IntPtr.Zero,
                (uint)msPerFrame,
                (uint)msPerFrame,
                0
                );

            return(Disposable.Create(() =>
            {
                timerDelegate = null;
                UnmanagedMethods.DeleteTimerQueueTimer(_timerQueue, timer, IntPtr.Zero);
            }));
        }