dispatchtimer to work in vb.net?
I cant get the dispatchtimer to work in vb.net.
I want the MainGameLoop() code to run every 20MS after i click abutton but this doesnt do that.
Dim dt As DispatcherTimer
Private Sub mybutton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles mybutton.Click
dt = New DispatcherTimer
dt.Interval = TimeSpan.FromMilliseconds(20)
' Dim MainGameLoop As EventHandler
' AddHandler dt.Tick, MainGameLoop
MainGameLoop() 'just runs once
End Sub
Private Sub MainGameLoop()
Re: dispatchtimer to work in vb.net?
Hi,
I think you forgot to start the timer:
Wkr,
sparrow1
Re: dispatchtimer to work in vb.net?
Quote:
Originally Posted by sparrow1
Hi,
I think you forgot to start the timer:
Wkr,
sparrow1
dt.Enable = True 'error as it is read only
i have to add handler somehow?
Re: dispatchtimer to work in vb.net?
Hi,
Forgot one lettre try this:
Re: dispatchtimer to work in vb.net?
forget this as there is no .Enabled property but just this and it is Read Only.
dt.IsEnabled = True 'error as read only
Re: dispatchtimer to work in vb.net?
Hi,
Try this:
Hope it helps this time,
sparrow1
Re: dispatchtimer to work in vb.net?
NO it just runs the code once .
The timer is not running every interval set.
I am not adding a timer with an event properly as shown below as i dont know how to do.
Dim dt As DispatcherTimer
Private Sub mybutton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles mybutton.Click
dt = New DispatcherTimer
dt.Interval = TimeSpan.FromMilliseconds(20)
' Dim MainGameLoop As EventHandler
' AddHandler dt.Tick, MainGameLoop
dt.start()
MainGameLoop() 'just runs once
End Sub
Re: dispatchtimer to work in vb.net?
Code:
Dim dt As DispatcherTimer
Private Sub mybutton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles mybutton.Click
dt = New DispatcherTimer '<<<------- Do you want a new timer every click?? If not move this.
dt.Interval = TimeSpan.FromMilliseconds(20)
AddHandler dt.Tick, addressof MainGameLoop
dt.start()
End Sub
Private Sub MainGameLoop(ByVal sender As Object, ByVal e As EventArgs)
End Sub
I don't have SPOT so ...