views:

38

answers:

1

Hey, I have an WPF application and using DispatcherTimer to fire an event every minute. I run my app and the cpu load jumps to 100%. I tried to compile an app without using a timer and cpu load was very low as I it expected to be.

Sample code:

DispatcherTimer MainTimer = new DispatcherTimer();
MainTimer.Tick += new EventHandler(Core.Timers.MainTimer_Tick);
MainTimer.Interval = TimeSpan.FromSeconds(60);
MainTimer.Start();

public static void MainTimer_Tick(object sender, EventArgs e)
{
 // initialize new class, do something...
}

Without that code cpu load is low. What should cause this?

Update Can I use som other timer? Accuracy isnt important.

A: 

I solved this with using System.Timers.Timer. It's behaving correctly.

daemonsvk