473,396 Members | 1,933 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,396 software developers and data experts.

System.Timers.Timer

All,
I have a Windows Service and it has one System.Timers.Timer that
fires every 500 milliseconds. Now I have noticed that there's a bug in
System.Timers.Timer when it's being used combined with Windows Service.
That is, the Timer won't fire again once it's stopped (Timer.Stop() or
Timer.Enabled = False) (http://support.microsoft.com/kb/842793/en-us).
Instead of using Threading.Timer, can I just have the code to run
inside the System.Timers.Timer Handler? However, this block of code
would take at least one or two seconds to run and it will go into the
database (using ADO). Would this cause a new Timer (Thread) to fire
since the process time is actually greater than the elapsed time?

Sample Code
Sub Timer1_TimerCallBack(ByVal source As Object, ByVal e As
Timers.ElapsedEventArgs)
'Don't stop the timer...

'Calling a sub and processing it.
DoSomthing()

End Sub

Private Sub DoSomthing()
'Processing and accessing the database...
End Sub
Thanks,
Carl

Dec 30 '05 #1
2 2169
I am using the System.Timers.Timer in a service and do not have a problem. In
the "Elapsed" event handler I toggle the "enabled" property before/after
processing.
Dec 30 '05 #2

I use timers all the time in windows services.

Why aren't you using the tick event?

cn****@gmail.com wrote:
All,
I have a Windows Service and it has one System.Timers.Timer that
fires every 500 milliseconds. Now I have noticed that there's a bug in
System.Timers.Timer when it's being used combined with Windows Service.
That is, the Timer won't fire again once it's stopped (Timer.Stop() or
Timer.Enabled = False) (http://support.microsoft.com/kb/842793/en-us).
Instead of using Threading.Timer, can I just have the code to run
inside the System.Timers.Timer Handler? However, this block of code
would take at least one or two seconds to run and it will go into the
database (using ADO). Would this cause a new Timer (Thread) to fire
since the process time is actually greater than the elapsed time?

Sample Code
Sub Timer1_TimerCallBack(ByVal source As Object, ByVal e As
Timers.ElapsedEventArgs)
'Don't stop the timer...

'Calling a sub and processing it.
DoSomthing()

End Sub

Private Sub DoSomthing()
'Processing and accessing the database...
End Sub
Thanks,
Carl

Dec 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Peter Johnsson | last post by:
How come the eventhandler for the timer's elapsed time event is called over and over again, even though the AutoReset property is set to false, if you assign a new value to the timer objects...
9
by: Mark Rae | last post by:
Hi, I've seen several articles about using System Timers in ASP.NET solutions, specifically setting them up in Global.asax' Application_OnStart event. I'm thinking about the scenario where I...
10
by: WhiteSocksGuy | last post by:
Help! I am new to Visual Basic .Net (version 2002) and I am trying to get a System.Timers.Timer to work for me to display a splash screen for about two seconds and then load the main form. I have...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
1
by: melanieab | last post by:
Hi, I'm have a datagrid, and I'm trying to have a tooltip pop up if a cell has been hovered on for 2 seconds. I was thinking of using DataGrid.Hover, but then decided to try this instead: ...
4
by: Liverpool fan | last post by:
I have a windows application written using VB .NET that encompasses a countdown timer modal dialog. The timer is a System.Timers.Timer with an interval of 1 second. AutoReset is not set so accepts...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
2
by: BobAtVandy | last post by:
I'll greatly appreciate any help on this. Actually 2 questions: 1. I believe I need to use the Windows timer System.Timers.Timer . The examples I find on the web all access that timer by...
8
by: Ollie Riches | last post by:
I'm looking into a production issue related to a windows service and System.Timers.Timer. The background is the windows service uses a System.Timers.Timer to periodically poll a directory location...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.