tags:

views:

310

answers:

3

I compiled my application with monodevelop. And tried to run with mono on Linux. It seems that the System.Windows.Forms.Timer objects' tick event never fires.

It runs without problems on windows, but not in Linux.

The related code roughly looks like this:

// 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();
//...
}
//....
A: 

I would suggest adding a Console.WriteLine in your OnControlCreated method to ensure that the method is getting called and the Timer is indeed being created.

jpobst
A: 

Even the simpliest winform application does not run the timer under mono...

But it runs if I place the initialization to the form1_load and then add it to the form.load event.

EDIT: OnCreateControl is working if you put a base.OnCreateControl() at the end of the method. On .NET it works without that line and worked under mono too before...

So it seems it's a bug in mono and I will report it.

Calmarius
A: 

Test it with mono 2.6 preview or latest svn. If it still doesn't work than submit a bug report.

Sharique