Hi,
I am coding on VB.net 2.0, trying to work with a windows service. The code is below:-
When I run from inside VS, the timer never actually fires. Same occurs when I install and try to run as a service (from control panel). I can confirm that my timer is System.Timers.Timer (and not the form based timer).
Can someone please give me an idea what is going on, and how to resolve it?
Much appreciated!
I am coding on VB.net 2.0, trying to work with a windows service. The code is below:-
VB.NET:
Imports System.ServiceProcess
Public Class Main
Public Shared Sub Main()
End Sub
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.
Timer1.Enabled = True
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
Timer1.Enabled = False
End Sub
Private Sub Timer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Dim Writer As New IO.StreamWriter(path:="C:\test.txt", Append:=True)
Writer.WriteLine("hi")
Writer.Close()
End Sub
End Class
When I run from inside VS, the timer never actually fires. Same occurs when I install and try to run as a service (from control panel). I can confirm that my timer is System.Timers.Timer (and not the form based timer).
Can someone please give me an idea what is going on, and how to resolve it?
Much appreciated!