M
Morten Snedker
Others had the same problem and I understand that I have to use the
System.Timers.Timer instead for the one for forms. So that's what I
do, but still it doesn't trigger:
'--code begin
Imports System.Net
Imports System.Net.Sockets
Imports System.Net.Dns
Imports System.Text
Imports System.IO
Public Class Service1
Private bTrigger As Boolean
Private myTimer As New System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
With myTimer
.Interval = 10000
.Enabled = True
.Start()
End With
LogFile(Now & ": " & vbTab & "Service started")
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop
your service.
LogFile(Now & ": " & vbTab & "Service stopped")
End Sub
Private Sub myTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
LogFile(Now & ": " & vbTab & "Timer trigger - do nothing")
If Minute(Now) = 33 Then
LogFile(Now & ": " & vbTab & "Timer trigger - run code")
If bTrigger = False Then ExecuteWOL()
End If
End Sub
....
'---code end
So, the file should be written to every 10 seconds, but it doesn't.
The file is correctly written to upon start/stop of service.
Any ideas?
Regards /Snedker
System.Timers.Timer instead for the one for forms. So that's what I
do, but still it doesn't trigger:
'--code begin
Imports System.Net
Imports System.Net.Sockets
Imports System.Net.Dns
Imports System.Text
Imports System.IO
Public Class Service1
Private bTrigger As Boolean
Private myTimer As New System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
With myTimer
.Interval = 10000
.Enabled = True
.Start()
End With
LogFile(Now & ": " & vbTab & "Service started")
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop
your service.
LogFile(Now & ": " & vbTab & "Service stopped")
End Sub
Private Sub myTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs)
LogFile(Now & ": " & vbTab & "Timer trigger - do nothing")
If Minute(Now) = 33 Then
LogFile(Now & ": " & vbTab & "Timer trigger - run code")
If bTrigger = False Then ExecuteWOL()
End If
End Sub
....
'---code end
So, the file should be written to every 10 seconds, but it doesn't.
The file is correctly written to upon start/stop of service.
Any ideas?
Regards /Snedker