T
Tihomir Ignatov
Hello,
I have the following problem with application, using System.Threading.Timer:
My app is Windows Forms (CF) and I have a MyTimer class in different
assembly. From my MainForm I open other form (SecondForm) and start
listening for Timer events from MyTimer and when notification arrives, I
want to increment a counter and show it in myLabel.For example I'm using
this code:
public class SecondForm: System.Windows.Forms.Form
{
private Label myLabel;
....
int counter = 0;
MyTimer myt = new MyTimer();
myt.MyTimerEvent += new TimerEventHandler(MyMethod);
....
private void MyMethod(object sender, MyEventArgs e)
{
this.Invoke(new EventHandler(CounterEH));
}
....
private void CounterEH(object sender, EventArgs e)
{
myLabel.Text = ++counter.ToString();
}
}// Class ends
The problem is, that myLabel.Text not changes it's value. Control.Invoke
method doesn't work !?!?! If I close SecondForm , MyTimerEvent
continues to arrives....
Any ideas?
Thanks
Regards
Tihomir Ignatov
I have the following problem with application, using System.Threading.Timer:
My app is Windows Forms (CF) and I have a MyTimer class in different
assembly. From my MainForm I open other form (SecondForm) and start
listening for Timer events from MyTimer and when notification arrives, I
want to increment a counter and show it in myLabel.For example I'm using
this code:
public class SecondForm: System.Windows.Forms.Form
{
private Label myLabel;
....
int counter = 0;
MyTimer myt = new MyTimer();
myt.MyTimerEvent += new TimerEventHandler(MyMethod);
....
private void MyMethod(object sender, MyEventArgs e)
{
this.Invoke(new EventHandler(CounterEH));
}
....
private void CounterEH(object sender, EventArgs e)
{
myLabel.Text = ++counter.ToString();
}
}// Class ends
The problem is, that myLabel.Text not changes it's value. Control.Invoke
method doesn't work !?!?! If I close SecondForm , MyTimerEvent
continues to arrives....
Any ideas?
Thanks
Regards
Tihomir Ignatov