How to achieve smooth UI updates every 16 ms?

前端 未结 3 439
滥情空心
滥情空心 2021-01-12 11:39

I am trying to create sort of a radar. Radar is VisualCollection that consists of 360 DrawingVisual\'s (which represent radar beams). Radar is placed on Viewbox.

<         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-12 12:18

    For smooth WPF animations you should make use of the CompositionTarget.Rendering event.

    No need for a thread or messing with the dispatcher. The event will automatically be fired before each new frame, similar to HTML's requestAnimationFrame().

    In the event update your WPF scene and you're done!

    There is a complete example available on MSDN.

提交回复
热议问题