I needed to set this as a windows service and set the start point of the project to this main.
Imports system.io
Imports System.Threading
Public Class MainClass
Private Shared aTimer As New System.Timers.Timer()
Shared Sub Main()
'End If
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
'' Set the Interval to 2 seconds (2000 milliseconds).
aTimer.Interval = 400
aTimer.Enabled = True
'Thread.CurrentThread.IsBackground = True
'Console.WriteLine("Press the Enter key to exit the program.")
'Console.ReadLine()
While True
Thread.Sleep(10000)
End While
'Keep the timer alive until the end of Main.
GC.KeepAlive(aTimer)
End Sub
' Specify what you want to happen when the Elapsed event is
' raised.
Private Shared Sub OnTimedEvent(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs)
Try
aTimer.Enabled = False
Dim displayForm As New Form1()
displayForm.textbox1.text = "something to display"
ad.ExecuteNonQuery(q)
displayForm.ShowDialog()
'This stuff is clean up and must come last
aTimer.Enabled = True
Catch ex As Exception
'do nothing dont alert user as this is going into background.
EventLog.WriteEntry("WindowsAppTest", ex.Message.ToString())
End Try
End Sub
End Class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment