I'm sure I'm missing something very basic here, am pretty much a newb in many ways, but two days of Googling and adjusting things haven't brought me an answer, so here's my question.
Currently I'm using a Timer control in an app (this is on the Compact Framework 2.0, but I don't think it matters). It works fine, fires every 10th of a second, checks the status of a port listener, does some utility work now and then, etc. The code that fires is in the Tick event.
I'm changing this to a console application, though, so don't have the Timer control there. Folks here helpfully suggested using System.Threading.Timer, which is indeed available to me (System.Timers is not, btw).
I think I get how these guys are supposed to work, but I'm having trouble. Here's a super basic application:
It seems to me, in my limited understanding, that if I start this application it will start the timer and every second it will call timerCallback, which will increment the counter.
What actually happens is the application starts up and then quits, all done, no errors. Like it ran and now it's finished, y'know?
What will make it... "run," if you will, just keep timing and running until I quit it? Does this relate to it being a console application?
Thanks much.
Currently I'm using a Timer control in an app (this is on the Compact Framework 2.0, but I don't think it matters). It works fine, fires every 10th of a second, checks the status of a port listener, does some utility work now and then, etc. The code that fires is in the Tick event.
I'm changing this to a console application, though, so don't have the Timer control there. Folks here helpfully suggested using System.Threading.Timer, which is indeed available to me (System.Timers is not, btw).
I think I get how these guys are supposed to work, but I'm having trouble. Here's a super basic application:
Code:
Module Core
Private timerCount As Integer = 0
Sub Main()
Dim myTimer As New System.Threading.Timer(AddressOf timerCallback, Nothing, 1000, 1000)
End Sub
Sub timerCallback(ByVal state As Object)
timerCount += 1
End Sub
End Module
What actually happens is the application starts up and then quits, all done, no errors. Like it ran and now it's finished, y'know?
What will make it... "run," if you will, just keep timing and running until I quit it? Does this relate to it being a console application?
Thanks much.