I've got a Silverlight 3 app that works great, except on 4 machines. DispatcherTimer and Storyboards are not firing consistently on these 4 machines. I've created a very simple test app to try to figure this out, I'll list the code below.
Basically the test app updates two TextBlocks every second. One using DispatcherTimer, one using a Storyboard Animation. This works great - the text boxes update "1, 2, 3..." every second. But on the 4 affected machines the TextBlocks don't update every second, they update between 27 and 33 seconds. The DispatcherTimer and Storyboard updates are done at the exact same time.
CPU, Memory, HD are all fine. Task Manager and SilverlightSpy shows that everything this is fine. These are all 3 Ghz workstations with 3GB of RAM with nothing else running on them.
XAML:
<TextBlock Text="0" Name="DispatcherTimerText" Grid.Column="0" />
<TextBlock Text="0" Name="SBLoopTimerText" Grid.Column="1" />
C#:
Storyboard _sbLoop = new Storyboard();
public MainPage()
{
InitializeComponent();
Storyboard_Start();
Timer_Start();
}
void Timer_Start()
{
System.Windows.Threading.DispatcherTimer dt1 = new System.Windows.Threading.DispatcherTimer();
dt1.Interval = new TimeSpan(0, 0, 1); // 1 second
dt1.Tick += new EventHandler(Timer_Tick);
dt1.Start();
}
void Timer_Tick(object sender, EventArgs e)
{
TextBlock txt = ((TextBlock)LayoutRoot.Children.Single(t => ((TextBlock)t).Name == "DispatcherTimerText"));
txt.Text = (int.Parse(txt.Text) + 1).ToString();
}
void Storyboard_Start()
{
_sbLoop.Duration = TimeSpan.FromSeconds(1);
_sbLoop.Completed += new EventHandler(StoryboardLoop);
_sbLoop.Begin();
}
void StoryboardLoop(object sender, EventArgs e)
{
TextBlock txt = ((TextBlock)LayoutRoot.Children.Single(t => ((TextBlock)t).Name == "SBLoopTimerText"));
txt.Text = (int.Parse(txt.Text) + 1).ToString();
_sbLoop.Begin(); // Restart sb animation
}