Sign In|Join
Home/Silverlight.NET Forums/Game Development/Lack of resolution in DateTime.Ticks/Re: Lack of resolution in DateTime.Ticks
All-Star
21645 Points
2132 Posts
Microsoft
Aug 26, 2009 02:31 AM | LINK
Hi,
How do you get the interval? By default, there are 60 frames per second in silverlight, which means it's 15-16 millseconds between frames.
If we calculate interval in CompositionTarget.Rendering event, then we would get 15-16 millseconds timespan.
To be more accurate, we could use TimeSpan.Ticks property, check this sample
public MainPage() { InitializeComponent(); CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering); } int precount; DateTime pretime; void CompositionTarget_Rendering(object sender, EventArgs e) { string str = "datetime.now.ticks:"; DateTime time = DateTime.Now; str += (time-pretime).Ticks; pretime = time; str += "environment.tickscount"; int count = Environment.TickCount; str += count-precount; precount = count; textblock1.Text = str; }
Mog Liang -...
All-Star
21645 Points
2132 Posts
Microsoft
Re: Lack of resolution in DateTime.Ticks
Aug 26, 2009 02:31 AM | LINK
Hi,
How do you get the interval? By default, there are 60 frames per second in silverlight, which means it's 15-16 millseconds between frames.
If we calculate interval in CompositionTarget.Rendering event, then we would get 15-16 millseconds timespan.
To be more accurate, we could use TimeSpan.Ticks property, check this sample
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.