|
-
May 27th, 2008, 07:10 AM
#1
Thread Starter
Hyperactive Member
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()
-
May 27th, 2008, 07:15 AM
#2
Re: dispatchtimer to work in vb.net?
Hi,
I think you forgot to start the timer:
Wkr,
sparrow1
-
May 27th, 2008, 07:30 AM
#3
Thread Starter
Hyperactive Member
Re: dispatchtimer to work in vb.net?
 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?
-
May 27th, 2008, 07:32 AM
#4
Re: dispatchtimer to work in vb.net?
Hi,
Forgot one lettre try this:
-
May 27th, 2008, 07:38 AM
#5
Thread Starter
Hyperactive Member
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
-
May 27th, 2008, 09:22 AM
#6
Re: dispatchtimer to work in vb.net?
Hi,
Try this:
Hope it helps this time,
sparrow1
-
May 27th, 2008, 05:45 PM
#7
Thread Starter
Hyperactive Member
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
-
May 28th, 2008, 07:15 AM
#8
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 ...
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
|