我用 monodevelop 编译了我的应用程序。并尝试在 Linux 上运行单声道。似乎 System.Windows.Forms.Timer 对象的 tick 事件从未触发。
它在 Windows 上运行没有问题,但在 Linux 上却没有。
相关代码大致如下:
// derived from a From
//...
private Timer controlTimer;
//....
protected override OnCreateControl(/*...*/)
{
//,,,
controlTimer=new Timer();
controlTimer.Tick += new EventHandler(controlFunc);
controlTimer.Interval = 40;
controlTimer.Tag = this; // The form is used by the callback
controlTimer.Start();
//...
}
//....
最佳答案
即使是最简单的 winform 应用程序也不会在单声道下运行计时器...
但如果我将初始化放在 form1_load 中,然后将其添加到 form.load 事件中,它就会运行。
编辑:如果您将 base.OnCreateControl() 放在方法的末尾,则 OnCreateControl 可以正常工作。 在 .NET 上,它可以在没有该行的情况下工作,并且之前也可以在单声道下工作......
所以这似乎是单声道中的一个错误,我会报告它。
关于c# - 在单声道下运行时,System.Windows.Forms.Timer 事件根本不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1763898/