The CompositionTarget.Rendering event is the perfect thing to build a game's main loop upon. It basically fires at the rate of vsync (usually 60 Hz).
Occurs just before the objects in the composition tree are rendered. The Rendering event is routed to the specified event handler after animation and layout have been applied to the composition tree.
The per-frame animation how-to article explains a little bit more.
Note that your event handler method is called after layout has been computed. However, you can modify layout in your event handler method, which means that layout will be computed once more before rendering.
Based on that, the rules for code inside its handler are:
- Avoid changing layout
- Return quickly
What other gotchas are there? What non-obvious actions cause another layout pass? How much time exactly do I have inside the handler?