Re: Timer Tick Event not Working in Windows Service
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 07/13/04
- Next message: Ken Kolda: "Re: C# main class access"
- Previous message: Ken Kolda: "Re: Casting back up the inheritance chain"
- In reply to: J. Hill: "Timer Tick Event not Working in Windows Service"
- Next in thread: J. Hill: "Re: Timer Tick Event not Working in Windows Service"
- Reply: J. Hill: "Re: Timer Tick Event not Working in Windows Service"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 13 Jul 2004 17:34:25 -0500
J.
In addition to the other comments.
In addition to the others comments, the following articles in MSDN Magazine
explain the difference between the three timer objects in .NET & when to use
each.
http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx
http://msdn.microsoft.com/msdnmag/issues/04/03/default.aspx
The above articles also discusses if & how each timer interacts with
threading.
I'm using System.Timers.Timer (instead of System.Threading.Timer) in my
Windows Service, as I don't really need the extra features of
System.Threading.Timer. Either should work in your case.
Hope this helps
Jay
"J. Hill" <J. Hill@discussions.microsoft.com> wrote in message
news:C78F64BF-BE17-43E4-BF68-8532307A53D4@microsoft.com...
> I have a Windows Service with a timer but the .Tick event is not being
fired/called.
>
> Don't know what code to include...I enabled and started the timer...I have
the exact same code in a Windows form and it works fine, but in the service:
nothing.
>
> ...
> this.components = new System.ComponentModel.Container();
> this.tmrTimer = new System.Windows.Forms.Timer(this.components);
> //
> // tmrTimer
> //
> this.tmrTimer.Interval = 6;
> this.tmrTimer.Tick += new System.EventHandler(this.tmrTimer_Tick);
>
> ...
>
> //In OnStart or Initialization -- tried both...
> tmrTimer.Start();
> tmrTimer.Enabled = true;
> /*
> also tried
> tmrTimer.Enabled = true;
> tmrTimer.Start();
> */
> ...
> private void tmrTimer_Tick(object sender, System.EventArgs e) {
> tCurrTime = DateTime.Now;
> EventLog.WriteEntry("Timer Tick", "We have ticked...",
> EventLogEntryType.Error);
>
> if (tCurrTime.Hour == 0){
> DoMidNightService();
> }
>
>
>
>
> Even a "did you check this" would be a great help.
>
> Thanks,
> J.
- Next message: Ken Kolda: "Re: C# main class access"
- Previous message: Ken Kolda: "Re: Casting back up the inheritance chain"
- In reply to: J. Hill: "Timer Tick Event not Working in Windows Service"
- Next in thread: J. Hill: "Re: Timer Tick Event not Working in Windows Service"
- Reply: J. Hill: "Re: Timer Tick Event not Working in Windows Service"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|