项目中非常奇怪的东西-计时器不计时 [英] Very weird stuff in project - timers not ticking

查看:96
本文介绍了项目中非常奇怪的东西-计时器不计时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我已经开发多年了,从未经历过这类问题.

此项目未与应用程序框架一起运行(从main子目录中运行,因此也许我必须手动启用某些功能)

1)System.Windows.Forms.Timer的计时器在启用它们(并执行开始"方法)后不会打钩,但是System.Timers.Timer的确能完美执行.

2)在输入表单之前(在application.run之前),MessageBox弹出窗口可以,但是一旦输入主表单,则不会弹出消息框(MsgBox也不起作用)

请帮忙.

提前谢谢.

E

Hi.
I''ve been developing for years and have never experienced these type of problems.

This project is not running with application framework (running from main sub so maybe i must enable something manually)

1) Timers of System.Windows.Forms.Timer don''t tick after enabling them (And executing the "Start" method), however, System.Timers.Timer do execute perfectly.

2) MessageBox popup OK before entering the form (before application.run) but once entered the main form messageboxes don''t popup (Nor does MsgBox work)

Please help.

Thanks in advance.

E

推荐答案

您的主体必须用单线程Apartment Attribute装饰,例如
这个:
Your main must be decorated with a single thread Apartment Attribute like
this:
[STAThread]
public static void main(string[] args)



为了使System.Windows.Forms.Timer正常工作.

这也可能是MessageBox的问题,
UI事件不会使用此属性执行.



In order for the System.Windows.Forms.Timer to work.

This might be the problem with the MessageBox also,
the UI Events don''t execute with this attribute.


这篇关于项目中非常奇怪的东西-计时器不计时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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