I am attempting to write some code (in a VB web application) using a timer that executes every 5 seconds. So far the only code I've found that does this task is similar to:
<%@ import Namespace="System.Timers" %>
Public Sub ProcessTimerEvent(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
Response.Write("Timer Fired!"
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
' call function every 5 seconds to do something
TimerRec = New System.Timers.Timer()
AddHandler TimerRec.Elapsed, AddressOf ProcessTimerEvent
TimerRec.Interval = 5000
TimerRec.Enabled = True
End Sub
But it doesn't work! So essentially I would like the words "Timer Fired!" should be displayed every 5 seconds, but I don't see that on the screen. Can anyone help me fix this bit of code so the timer actually fires and does something useful?
<%@ import Namespace="System.Timers" %>
Public Sub ProcessTimerEvent(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
Response.Write("Timer Fired!"
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
' call function every 5 seconds to do something
TimerRec = New System.Timers.Timer()
AddHandler TimerRec.Elapsed, AddressOf ProcessTimerEvent
TimerRec.Interval = 5000
TimerRec.Enabled = True
End Sub
But it doesn't work! So essentially I would like the words "Timer Fired!" should be displayed every 5 seconds, but I don't see that on the screen. Can anyone help me fix this bit of code so the timer actually fires and does something useful?