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

Trouble getting timer tick to fire in Windows Service

Hello,

I'm trying run a process at regular intervals using a windows service. the
problem is, the timer_tick event doesn't appear to be working. I've written
the following code as a test;

Public Class FileName
Protected Overrides Sub OnStart(ByVal args() As String)

Timer1.Interval = 1000
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

If Not EventLog.SourceExists("Service1") Then
EventLog.CreateEventSource("Service1", "Application")
End If

EventLog1.Source = "Service1"
EventLog1.WriteEntry("This is a simple event log entry")

End Sub

Needless to say, there are no EventLog entries occurring. I've also tried
to attach to the process but again, it doesn't seem to fire.

Any direction would be greatly appreciated.

Thanks!
Rick


Mar 16 '07 #1
2 5765
"Rico" <me@you.comschrieb:
I'm trying run a process at regular intervals using a windows service.
the problem is, the timer_tick event doesn't appear to be working. I've
written the following code as a test;

Public Class FileName
Protected Overrides Sub OnStart(ByVal args() As String)

Timer1.Interval = 1000
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Note that 'System.Windows.Forms.Timer' does not work if its not placed on a
form. You may want to use 'System.Timers.Timer' or 'System.Theading.Timer'
instead.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 16 '07 #2
Excellent! That was the ticket!

Thanks Herfried!

Rick

"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:uq**************@TK2MSFTNGP04.phx.gbl...
"Rico" <me@you.comschrieb:
>I'm trying run a process at regular intervals using a windows service.
the problem is, the timer_tick event doesn't appear to be working. I've
written the following code as a test;

Public Class FileName
Protected Overrides Sub OnStart(ByVal args() As String)

Timer1.Interval = 1000
Timer1.Enabled = True

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Note that 'System.Windows.Forms.Timer' does not work if its not placed on
a form. You may want to use 'System.Timers.Timer' or
'System.Theading.Timer' instead.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 16 '07 #3

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

Similar topics

7
by: J. Hill | last post by:
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...
8
by: Daniel P. | last post by:
I'm trying to set a timer that gets called every 3 seconds so I can update a field in the UI with the time elapsed since the process started. What am I doing wrong that timerDF_Tick does not get...
7
by: Noozer | last post by:
I have a timer on a form. It isn't firing at all. I know that the timer is enabled, and that the interval is low (4000, which should be 4 seconds). To ensure the timer wasn't being inadvertantly...
10
by: Bob | last post by:
I have a splashscreen running on a thread from Sub Main and it works OK. It displays information in a statusbar about queries. I also have a time on the splashscreen, but the tick event never...
1
by: Manuel | last post by:
Used VS2005 to create a windows service and I can't make a timer trigger the tick/elapsed event. On the form viewer I dragged a timer from the components section of the toolbar, enabled it but...
2
by: cntams | last post by:
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...
9
by: archana | last post by:
Hi all, I want to know about interval of timer. I am using timer in windows service.I head somewhere that when i set interval property of timer while setting interval, restart time of Pc is...
8
by: KnighT | last post by:
I have a .net service that runs a System.Threading.Timer. The delegate points to the function that the service should execute when the timer elapses. Problem: The timer is not ticking. I have...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.