V
Varangian
Hi there,
I'm having problems using the Timer i.e. System.Timers.Timer (not the
one found on the toolbox) in a webapplication and its giving me
problems. Although I'm setting the interval to 5 secs (5000millisecs)
it seems that this interval is not being followed correctly. I'm using
Elapsed event to make something and this event is being raised
bizarrely after 2 secs, or after 3, sometimes after 5, sometimes less
than 1 sec :S or 2 in a row. I don't know, maybe doing something
incorrectly.
I tested this timer in WindowApplication, maybe because the Timer
doesn't work correctly on web. However it still does the same, i.e.
raising the event not following the correct interval. Below I have a
sample code of the timer in WindowsApplication but with no success at
all.
Any help appreciated thanks
private void button1_Click(object sender, System.EventArgs e)
{
System.Timers.Timer test = new System.Timers.Timer();
test.Interval = 5000;
test.Enabled = true;
test.Elapsed +=new System.Timers.ElapsedEventHandler(test_Elapsed);
}
private void test_Elapsed(object sender, System.Timers.ElapsedEventArgs
e)
{
MessageBox.Show ("SHOW");
}
I'm having problems using the Timer i.e. System.Timers.Timer (not the
one found on the toolbox) in a webapplication and its giving me
problems. Although I'm setting the interval to 5 secs (5000millisecs)
it seems that this interval is not being followed correctly. I'm using
Elapsed event to make something and this event is being raised
bizarrely after 2 secs, or after 3, sometimes after 5, sometimes less
than 1 sec :S or 2 in a row. I don't know, maybe doing something
incorrectly.
I tested this timer in WindowApplication, maybe because the Timer
doesn't work correctly on web. However it still does the same, i.e.
raising the event not following the correct interval. Below I have a
sample code of the timer in WindowsApplication but with no success at
all.
Any help appreciated thanks
private void button1_Click(object sender, System.EventArgs e)
{
System.Timers.Timer test = new System.Timers.Timer();
test.Interval = 5000;
test.Enabled = true;
test.Elapsed +=new System.Timers.ElapsedEventHandler(test_Elapsed);
}
private void test_Elapsed(object sender, System.Timers.ElapsedEventArgs
e)
{
MessageBox.Show ("SHOW");
}