473,378 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 3718
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: curious | last post by:
I am new to VB.NET and I need help in using timer control. Here is the scenario. I have 3 labels (label 1, label2, label 3), and a start button, all vertically aligned on the form. Using a...
4
by: William Bub | last post by:
Is there an accurate way to create a "stopwatch" good to 1/10 of a second? I'm not sure if I should use the timer control, or some way to access the computer timer. I found the following site...
3
by: David | last post by:
Hi There! I'm using Timer control to record how long my application perform certain tasks. However, apparently Timer control is not doing its' job (i.e. Not firing Tick event) while my...
11
by: John | last post by:
Hi Is there a way to force a vertical scroll bar on the data grid, even if the data grid has no rows? Thanks Regards
6
by: Steve | last post by:
I am working on a emulator and need to have time based events. I've tried to use the timer control and discovered that it runs waaaaaaay slow. I set the tick frequency to 1, then in the tick...
1
by: abhishek007p | last post by:
HI, i am using visual web developer for .net 2.0. does .NET 2.0 comes with a timer control, i was unable to find it in the IDE, where is it ? thanks, Abhishek
3
by: Francois Stander | last post by:
Hi, Could anyone assist me. I wrote a windows application and is tested successfully. This app must run as a windows service, so I copied the code into a new "windows service project" The problem is...
5
by: Peted | last post by:
Just some threading questions 1. in a MDI app if you have multiple child forms, does each child form run in its own thread ? Eg do you get error trying to update one control on form1 from...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.