Welcome to irritatedVowel.com Sign in | Help

POKE 53280,0: Pete Brown's Blog

Silverlight, WPF, Windows Client Development, Woodworking, .NET Programming, CNC, Nature, and other topics.

Subscribe

Subscribe to my feed
Add to Technorati Favorites

My Book

Order my upcoming book, Silverlight in Action, covering Silverlight 4, ViewModel/MVVM, WCF RIA Services, MEF and more

About Pete Brown

Pete Brown is a Microsoft Developer Division Community Program Manager, focusing on Windows Client Development as well as a former Microsoft Silverlight MVP and INETA Speaker. Pete writes on a number of topics including Silverlight, WPF, .NET, woodworking and working as a consultant in the DC area. read more

Community Events


who's online

AddThis Social Bookmark Button

Silverlight 2 Per-Frame Rendering Callback – CompositionTarget.Rendering Event

While promised early on, this one seemingly snuck in under the radar :)

Silverlight 2 now has the CompositionTarget.Rendering event.

So now, if you want to do something each frame, this is one place where you can do it. You’ll want to do some testing to see just how much you can pack in there before causing problems for your app.

Where would you use this? On possibility would be when you need to build up the display for some complex animation or a gameloop. If you don’t have your gameloop synchronized exactly with the rendering system, you may be doing more work (drawing things twice, for example) or not enough work (drawing only once every three frames). Granted, you are tied to the frames-per-second in this case, and not to a timer, but sometimes that’s exactly what you want.

CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
void CompositionTarget_Rendering(object sender, EventArgs e)
{
    // do something each frame
}

It's as simple as that.

  Add to Technorati Favorites
Posted: Monday, September 29, 2008 1:32 PM by Pete.Brown
Filed under: ,

Comments

2008 September 30 - Links for today « My (almost) Daily Links said:

PingBack from http://mgalinks.wordpress.com/2008/09/30/2008-september-30-links-for-today/
# September 30, 2008 3:53 AM

Andrew L said:

Belated thanks for this great news! I've become quite accustomed to designing animation-orientated WPF applications around the Rendering event, so I was more than a little worried when it was omitted from Silverlight 1.0. I'm very pleased that Microsoft has added it to Silverlight 2.0.
# January 1, 2009 1:28 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Enter the text you see in the image:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS