计时器显示表单过期. [英] show form on timer expire.

查看:92
本文介绍了计时器显示表单过期.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用system.timer.
计时器到期后,我想打开一个表单.

I am using system.timer.
On timer expire i want to open a form.

void onExpire(...) { 
     myform ^ frm = gcnew myform();
     frm->show(); 
}   


但它没有响应.
请帮帮我.


But its not responding.
Please help me out.
Is there a syncObj issue or what?

推荐答案

首先,没有System.Timer.计时器分为三种类型;请参阅我最近的解决方案计时器启动和启用的差异 [ ^ ].

现在,有两种可能的问题:1)是否曾经调用过您的计时器事件处理程序或回调(在System.Threading.Timer的情况下)?和2)处理程序正确吗?

什么都没有告诉我,您曾经将该方法用作System.Threading.Timer的回调方法onExpire,或者在使用其他两个计时器的情况下已添加到计时器事件的调用列表中.确保您做到了.由于我不知道您的计时器类型,请使用我在上面引用的我过去的答案中引用的MSDN帮助页面自行完成操作.在onExpire的开头放置一个断点以确保.不要忘记启用,启动计时器,设置经过的时间等.

如果使用两个计时器,则可以在UI线程之外的其他线程中调用even或callback,则请使用调用,上面我在前面的回答中也对此进行了解释.

—SA
First, there is no System.Timer. There are three types of timers; see my recent solution difference of start and enable in timers[^].

Now, there are two kinds of possible issue: 1) is your timer event handler or callback (in case of System.Threading.Timer) ever called? and 2) is the handler correct?

Nothing tells me you ever used the method as a callback method onExpire for System.Threading.Timer or added to the invocation list to the timer event in case of two other timers. Make sure you do it. As I don''t know your timer type, do it by yourself using the MSDN help pages I reference in my past answer referenced above. Put a breakpoint on the start of onExpire to make sure. Don''t forget to enable, start timer, setup elapsed time, etc.

If the case of two timers your even or callback could be called in a thread other then your UI thread, so use invocation, which is also explained in my past answer referenced above.

—SA


这篇关于计时器显示表单过期.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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