471,319 Members | 1,267 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Timer control in webapplication

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");
}

Dec 27 '05 #1
4 3630
Hi,
Where are you setting the timer?

Also, why are you using a timer in a web app?
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Varangian" <of****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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");
}

Dec 27 '05 #2
Hello Ignacio Machin, pondering about my situation I don't think the
timer has any used. Thanks for the reply anyway :). I may use the
Threading.Sleep :)

Dec 28 '05 #3

"Varangian" <of****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hello Ignacio Machin, pondering about my situation I don't think the
timer has any used. Thanks for the reply anyway :). I may use the
Threading.Sleep :)


And why would you put a webrequest to sleep?

Willy.
Dec 28 '05 #4
Hi,
"Varangian" <of****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hello Ignacio Machin, pondering about my situation I don't think the
timer has any used. Thanks for the reply anyway :). I may use the
Threading.Sleep :)


Even worse !, you will get a timeout in the browser, IIS is configured to
not allow a request to run more than a given amount of time, otherwise a bad
programmed pages can take down the entire service.

What is what you want to do? that is what you have to explain in the first
place.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 28 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by curious | last post: by
4 posts views Thread by William Bub | last post: by
11 posts views Thread by John | last post: by
6 posts views Thread by Steve | last post: by
1 post views Thread by abhishek007p | last post: by
3 posts views Thread by Steve | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.