我需要快速计算我的 Windows 8 应用商店应用程序。所以我将间隔设置为 10 Ticks。因为我们每秒有 10,000,000 个滴答声,这就足够了。但结果我只得到了大约 30 个刻度。如何获得更快的计时器?
我的定时器代码(和控制定时器):
int GLOBAL_counter = 0;
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromTicks(10);
timer.Tick += timer_Tick;
timer.Start();
DispatcherTimer timerControl = new DispatcherTimer();
timerControl.Interval = TimeSpan.FromSeconds(1);
timerControl.Tick += timer_Tick_timerControl;
timerControl.Start();
}
private void timer_Tick(object sender, object e)
{
GLOBAL_counter++;
}
private void timer_Tick_timerControl(object sender, object e)
{
Label1.Text += GLOBAL_counter.ToString() + "\r\n";
GLOBAL_counter = 0;
}