-
Oct 9th, 2009, 03:36 PM
#1
Thread Starter
PowerPoster
[RESOLVED] Timers VS DoEvents()
can i use the DoEvents() key code line in a Timer(with short interval(100 or less)), without a problem?
the cicle works normaly or sametimes can be ignored?
thanks
-
Oct 9th, 2009, 03:42 PM
#2
Re: Timers VS DoEvents()
You can run into problems. DoEvents allows re-entrance into code. A short interval like that may not cause problems but you can avoid it...
Example to prevent timer1 from firing again before it finishes:
Code:
Private Sub Timer1_Timer()
If Timer1.Tag = "" Then
Timer1.Tag = "no recursion"
do stuff
DoEvents
Timer1.Tag = ""
End If
End Sub
-
Oct 9th, 2009, 04:14 PM
#3
Thread Starter
PowerPoster
Re: Timers VS DoEvents()
Originally Posted by LaVolpe
You can run into problems. DoEvents allows re-entrance into code. A short interval like that may not cause problems but you can avoid it...
Example to prevent timer1 from firing again before it finishes:
Code:
Private Sub Timer1_Timer()
If Timer1.Tag = "" Then
Timer1.Tag = "no recursion"
do stuff
DoEvents
Timer1.Tag = ""
End If
End Sub
hi LaVolte
sorry the interval is 10.
i have like these:
Code:
Private Sub Timer1_Timer()
If something Then
do stuff
raiseevent Move
DoEvents
do stuff
raiseevent Collision()
'i try use Doevents too
elseif
do stuff
raiseevent someevent
End If
End Sub
[/QUOTE]
tell me what you think?
i know that these isn't the real code, but we are speak about timers and Doevents() keyword.
thanks
-
Oct 9th, 2009, 04:17 PM
#4
Re: Timers VS DoEvents()
Timers are asynchronous. They run in their separate thread. You do not need to call DoEvents inside it because it yields to the system after each cycle by itself.
-
Oct 9th, 2009, 04:22 PM
#5
Re: Timers VS DoEvents()
You can also use a flag to determine when to continue"
Do Until mDone = True
DoEvents
Loop
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders
-
Oct 9th, 2009, 04:27 PM
#6
Thread Starter
PowerPoster
Re: Timers VS DoEvents()
then the colision event(i'm speak in new UC), is, always, called without a problem, right?
but my event isn't always called
can you tell me more that you know?
-
Oct 9th, 2009, 04:54 PM
#7
Re: Timers VS DoEvents()
in VB6 timers are not accurate. So it is possible that you won't get the events at exactly 10ms. If you are looking for better accuracy, you may use API timers instead.
-
Oct 9th, 2009, 05:38 PM
#8
Thread Starter
PowerPoster
Re: Timers VS DoEvents()
Originally Posted by Pradeep1210
in VB6 timers are not accurate. So it is possible that you won't get the events at exactly 10ms. If you are looking for better accuracy, you may use API timers instead.
i don't know use the API timers
(note: you can see the problem here: http://www.vbforums.com/showpost.php...28&postcount=4. download the project and change the FileName property. then move RUN it and move the sonic by walls. you well see that not everytime that tatch the wall he do what must do)
thanks
-
Oct 9th, 2009, 05:50 PM
#9
Re: Timers VS DoEvents()
I don't have VB6 on this machine. So I won't be able to have a look at it.
But just search this forum; you would find many examples of timers using API.
Last edited by Pradeep1210; Oct 9th, 2009 at 05:54 PM.
-
Oct 9th, 2009, 05:52 PM
#10
Thread Starter
PowerPoster
Re: Timers VS DoEvents()
Originally Posted by Pradeep1210
I don't have V6 on this machine. So I won't be able to have a look at it.
But just search this forum; you would find many examples of timers using API.
ok.. thanks
but i woud like that someone test it and tell me something
please someone...
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
|