Wrox Programmer Forums
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 17th, 2004, 02:55 AM
Friend of Wrox
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default Timers in a Windows Service

I have a fairly simple windows service I've designed, but after deploying it I found it wasn't working. After a bit of messing about I got remote debugging working, and found that the reason was that the timer wasn't ticking. I created a new service, which would write to a text file on every timer tick (once every 60,000 milliseconds, or 1 minute), and this doesn't work either.

Now the timer.enabled property defaults to false, but in the OnStart sub I set it to true and again in the OnStop I set it to false. The timer is definitely enabled, because I also put Pause and Continue routines in the first service and when stepping though these, the timer.enabled property does change (and is set to true when exiting the Continue routine).

Anyone else encountered a similar problem?

Old June 17th, 2004, 03:04 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

Did you also start the timer? e.g.:


I think this method is new in .NET. In classic VB, setting it to enabled meant it would start automatically (at least I think that was the case), but in the .NET world you have to start it yourself.


Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Back To School by Jon & Vangelis (Track 6 from the album: The Friends Of Mr. Cairo) What's This?
Old June 18th, 2004, 05:31 AM
Friend of Wrox
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts

Nope, realised that I was using a System.Windows.Forms.Timer rather than a System.Timers.Timer (how stupid of me!). I can't really understand why the dot net designers thought having two timer classes that both perform in almost identical ways was a good idea, but what do I know...

Similar Threads
Thread Thread Starter Forum Replies Last Post
Impersonate with windows service for Service A/C vinod_yadav1919 C# 0 October 18th, 2008 02:29 PM
Accessing Windows service from a windows app sajid08 C# 1 October 6th, 2006 10:25 AM
Windows Service hunghung General .NET 3 January 20th, 2005 01:43 PM
c# timers donbes C# 0 June 19th, 2003 11:19 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.