private static void CompositionTarget_Rendering(object sender, EventArgs e) { var args = (RenderingEventArgs)e; if (args.RenderingTime == _last) { return; } _last = args.RenderingTime; FrameUpdating?.Invoke(sender, args); }
// checks if the CompositionTarget.Rendering was launched during a new frame // and in such case, launches the frame updating event private static void OnRendering(object sender, EventArgs genericArgs) { var renderingArgs = genericArgs as RenderingEventArgs; if (renderingArgs.RenderingTime == RecentTargetTime) { return; } RecentTargetTime = renderingArgs.RenderingTime; FrameUpdating?.Invoke(sender, renderingArgs); }