How Do I...Get timer events without message pump?
Timer allows you to raise an event on a specified interval.
This sample illustrates how to use a
Timer to raise an event every 1000 milliseconds.
Run the sample and observe a new "Hello World" message being printed every second.
In its simplest form, using a
Timer involves:
- Creating a new instance of Timer:
Dim aTimer As System.Timers.Timer = New System.Timers.Timer()
VB
|
- Specifying the event handler:
AddHandler aTimer.Tick, AddressOf OnTimer
VB
|
- Specifying how often to raise the event:
- Enabling the component:
- Handling the event:
Public Shared Sub OnTimer(ByVal source As Object, ByVal e As EventArgs)
Console.WriteLine("Hello World!")
End Sub
VB
|
Example
Copyright 2001-2002 Microsoft Corporation. All rights reserved.