S
Sagar
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
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