private void OnRendering(object sender, TimeSpan e)
        {
            if (_frameEventArgs == null)
            {
                _mutableReference = _frameEventArgs = new FrameEventArgs(e);
            }
            else
            {
                _mutableReference.Update(e);
            }

            DispatchUICallback?.Invoke(this, _frameEventArgs);
            NativeAnimatedCallback?.Invoke(this, _frameEventArgs);
            JavaScriptEventsCallback?.Invoke(this, _frameEventArgs);
            IdleCallback?.Invoke(this, _frameEventArgs);

            lock (_gate)
            {
                if (_callbackKeys.Count == 0)
                {
                    if (++_currentInactiveCount >= InactiveFrameCount)
                    {
                        Unsubscribe();
                    }
                }
                else
                {
                    _currentInactiveCount = 0;
                }
            }
        }
示例#2
0
        private void OnRendering(object sender, object e)
        {
            var renderingArgs = e as RenderingEventArgs;

            if (renderingArgs == null)
            {
                throw new InvalidOperationException("Expected rendering event arguments.");
            }

            var renderingTime = renderingArgs.RenderingTime;

            if (_frameEventArgs == null)
            {
                _mutableReference = _frameEventArgs = new FrameEventArgs(renderingTime);
            }
            else
            {
                _mutableReference.Update(renderingTime);
            }

            DispatchUICallback?.Invoke(sender, _frameEventArgs);
            NativeAnimatedCallback?.Invoke(sender, _frameEventArgs);
            JavaScriptEventsCallback?.Invoke(sender, _frameEventArgs);
            IdleCallback?.Invoke(sender, _frameEventArgs);

            lock (_gate)
            {
                if (_callbackKeys.Count == 0)
                {
                    if (++_currentInactiveCount >= InactiveFrameCount)
                    {
                        CompositionTarget.Rendering -= OnRendering;
                        _isSubscribed = false;
                    }
                }
                else
                {
                    _currentInactiveCount = 0;
                }
            }
        }
示例#3
0
        private void OnRendering(object sender, object e)
        {
            var renderingArgs = e as RenderingEventArgs;

            if (renderingArgs == null)
            {
                throw new InvalidOperationException("Expected rendering event arguments.");
            }

            var renderingTime = renderingArgs.RenderingTime;

            if (_frameEventArgs == null)
            {
                _mutableReference = _frameEventArgs = new FrameEventArgs(renderingTime);
            }
            else
            {
                _mutableReference.Update(renderingTime);
            }

            DispatchUICallback?.Invoke(sender, _frameEventArgs);
            NativeAnimatedCallback?.Invoke(sender, _frameEventArgs);
            JavaScriptEventsCallback?.Invoke(sender, _frameEventArgs);
        }