Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Windows service Timer elapsed event not firing

Reply
 
Old 03-28-2009   #1 (permalink)
Sagar


 
 

Windows service Timer elapsed event not firing

Hi,

I wrote a simple windows service program with a timer. The timer
doesnt seem to be firing the elapsed event.

Can someone tell why ? whats the problem with this code ?

Thanks,
Anand
-----------------------

Imports System.IO
Imports System.Timers
Public Class goodmorningalarm

Private WithEvents myTimer As New System.Timers.Timer(100)

Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set
things
' in motion so your service can do its work.


AddHandler myTimer.Elapsed, AddressOf DoSomething
myTimer.Start()
myTimer.Enabled = True

End Sub

Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop
your service.
myTimer.Enabled = False
End Sub

Function DoSomething() As Integer
MsgBox("test")

'Dim wr As New StreamWriter("c:\test.txt")
'wr.Write("Hello")

Return 1
End Function


End Class

My System SpecsSystem Spec
Old 03-28-2009   #2 (permalink)
MBUnit


 
 

Re: Windows service Timer elapsed event not firing

Sagar wrote:
Quote:

> Hi,
>
> I wrote a simple windows service program with a timer. The timer
> doesnt seem to be firing the elapsed event.
>
> Can someone tell why ? whats the problem with this code ?
>
> Thanks,
> Anand
Maybe, the service has blown-up/aborted and you don't know it.
My System SpecsSystem Spec
Old 03-28-2009   #3 (permalink)
Sagar


 
 

Re: Windows service Timer elapsed event not firing

Doesnt help, I would've expected a precise reply.

Anyways, Are you saying the code is correct and should work without
issues ?

I am doing this coding in vb.net 2008

Regards,
Anand
My System SpecsSystem Spec
Old 03-28-2009   #4 (permalink)
MBUnit


 
 

Re: Windows service Timer elapsed event not firing

Sagar wrote:
Quote:

> Doesnt help, I would've expected a precise reply.
>
> Anyways, Are you saying the code is correct and should work without
> issues ?
No, I am saying you don't have a try/catch no where to be found in the
code, and it may have blown up. Do you even know how to debug a Windows
service by attaching a debugger to the Window service process?

If things are not firing, it's because it never made it to do the firing
is the most likely cause of the problem.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
HELP need to solve this problem asap - Unable to start event viewer/event log service Software
dynamic loaded ascx delegate event not firing in parent form .NET General
Windows Event Log service will not start Vista General
Timer event failing sporadically -- Office 2007 VBA Vista General
Can't start Windows Event Log service Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46