我需要一些关于DispatcherTimer的帮助[已解决] [英] I need some help about DispatcherTimer[SOLVED]

查看:103
本文介绍了我需要一些关于DispatcherTimer的帮助[已解决]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += timer_Tick; // i take some error here. "Doesn't exist in the current context"
timer.Start();



我收到有关timer.Tick + = timer_Tick的错误。我该怎么做?添加一些使用字样或什么?

提前谢谢。


I take errors about "timer.Tick += timer_Tick". What should I make there? Add some "using" words or what?
Thanks in advance.

推荐答案





你应该创建一个 timer_Tick 方法:

Hi,

You should create a timer_Tick method:
private void timer_Tick(object sender, EventArgs e)
{
     // your code here
}



如果将此方法添加到类中,则不会再出现当前上下文中不存在错误。



希望这会有所帮助。


If you add this method to your class, you don't longer get the "Doesn't exist in the current context" error.

Hope this helps.


这篇关于我需要一些关于DispatcherTimer的帮助[已解决]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆