RE: Timer in a plug-in
I created timer function without much problem using the VB.Net sample.
Declare a timer object for the class as below
Dim _Timer As System.Timers.Timer
In the Initialize function, add
Try
_Timer = New System.Timers.Timer(30000)
AddHandler _Timer.Elapsed, AddressOf OnTimedEvent
_Timer.Start()
Catch ex As Exception
LogError(ex.Message.ToString())
End Try
Initialize = True
LogError just writes to a text file
Add the Timer event(callback function)
Public Sub OnTimedEvent(ByVal source As Object, ByVal e As System.Timers.ElapsedEventArgs)
'_Timer.Stop()
LogError("Timer Event")
DisplayToast("Hello World", "Plus Test", "http://www.google.com", True)
End Sub
It works great. I am getting the "Timer Event" message in the log file every 30 seconds.
Now for my problem, DisplayToast does not work. If I put it in the Initialize function, it works. Can someone please explain ?
Thanks
|