Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / December 2005

Tip: Looking for answers? Try searching our database.

System.Timers.Timer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cntams@gmail.com - 30 Dec 2005 04:59 GMT
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
Brad Roberts - 30 Dec 2005 18:08 GMT
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.
John A. Bailo - 30 Dec 2005 18:27 GMT
I use timers all the time in windows services.

Why aren't you using the tick event?

> All,
>      I have a Windows Service and it has one System.Timers.Timer that
[quoted text clipped - 24 lines]
> Thanks,
> Carl

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.