-
Sep 3rd, 2012, 02:10 PM
#1
Thread Starter
Member
Timer Elapsed Event?
So I can't seem to get the elapsed event for the timer to work as it won't run the code after the interval is complete. What am I doing wrong? The only other code besides the timer code is code to add a couple columns to a datagrid.
Code:
Imports System.Timers
Class MainWindow
Private WithEvents mainTimer As Timer
Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
'add columns to datagrid
Dim linkColumn As New DataGridTextColumn : Dim titleColumn As New DataGridTextColumn
linkColumn.Header = "Links:" : titleColumn.Header = "Titles:"
linkColumn.Width = DataGrid1.Width / 2 : titleColumn.Width = DataGrid1.Width / 2
linkColumn.Binding = New Binding("Links") : titleColumn.Binding = New Binding("Titles")
DataGrid1.Columns.Add(linkColumn) : DataGrid1.Columns.Add(titleColumn)
mainTimer.Interval = 100 : mainTimer.Enabled = True
End Sub
Private Sub mainTimer_Tick(sender As System.Object, e As ElapsedEventArgs) Handles mainTimer.Elapsed
MsgBox("wow")
End Sub
End Class
-
Sep 3rd, 2012, 04:13 PM
#2
Re: Timer Elapsed Event?
The error i see is that you have declared mainTimer but you didn't create an instance!
Try this
Code:
mainTimer = New Timer
mainTimer.Interval = 1000
mainTimer.Enabled = True
-
Sep 4th, 2012, 07:10 AM
#3
Thread Starter
Member
Re: Timer Elapsed Event?
*facepalm* Thanks for the help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|