Criel
Criel

Reputation: 815

Can you create a timer without the Timer component

I'm working on an application that requires a Timer to be running every 60 seconds to refresh the information on a 3270 mainframe. I would like to not have any GUI with it but I can't seem to find a way to have a Timer work without the Tick event, would it be possible to always have a Timer running until the user closes the application without having the Timer component in the application?

Upvotes: 2

Views: 397

Answers (2)

Et1
Et1

Reputation: 46

Try this:

Public Sub Wait(ByVal sec As Integer)
    sec = sec * 1000
    Dim sw As New Stopwatch
    sw.Start()
    Do Until sw.ElapsedMilliseconds >= sec
        Application.DoEvents()
        Threading.Thread.Sleep(1)
    Loop
    sw.Stop()
End Sub


Enjoy =)

Upvotes: 3

Reed Copsey
Reed Copsey

Reputation: 564451

Yes. You can use a System.Timers.Timer (or a System.Threading.Timer), and create this manually in the code.

The designer is not required to use these timers.

Upvotes: 5

Related Questions