First, avoid timers by all means. Use a separate thread instead with
System.Threading.Thread.Sleep
. This is much more reliable and more straightforward to program.
Secondly, it's hard to see you problem without looking at your code. Services are harder to debug. Use
System.Diagnostics.EventLog
and log to the system event log you can open and view via the command:
%SystemRoot%\system32\eventvwr.msc /s
See
http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[
^].
Another way is implementing most of you code in a separate assembly which you can use in you Windows Service and also in a regular interactive application, such as console application. However, remember that Windows Service is a very unusual host for running code: many aspects will look different. Create a very simple skeleton of the Windows Service first and make sure it works first, add some "meat" later step by step. Perform debug in both modes (interactive and Service) on regular basis.
Don't forget an important flag to use: the static property
System.Environment.UserInteractive
, see
http://msdn.microsoft.com/en-us/library/system.environment.userinteractive.aspx[
^]. Very useful.
—SA