[Help] Sleep Function
^Won'd change anything. The timer starts and does eveything in the timer's code THEN implements a delay. Once it does everything, it's disabled and the other one does everything in it's code THEN has a delay but it's already disabled and this repeats for an infinite loop. There is never any delay.
Ok well if you want delay b4 each timer at the top of the timers starting
(man do i look stupid i said to do this in the first place but i like timers i would do it on my comp then tell him how to make it 100% but i don't have CF) so i really have to get the code outa my head with out opening vb.
Code:
system.thread.threading.sleep(1000)
Sorry, Must have missed this thread entirely.
When Sleeping with threading or using Sharks API example to simulate sleep
[php]
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
[/php]
You are (for system.threading.sleep) causing not only your application to pause, but you are pausing the whole thread, you can work with multi threading to avoid this, but it isn't necessary. When using the API you are effecting the TMR Macro, which again can cause your application to pause and therefor lag any other running process. The way the .net framework has accommodated for that is with DoEvents() this allows you to continue processes already cued in the thread and cue new processes into the thread which will allow smoother pauses, I wrote a small snippet in the snippet vault.
http://www.mpgh.net/forum/33-visual-...ets-vault.html
[php]
Private Sub Sleep(ByVal PauseTime As Double)
Dim Tind As Int16
For Tind = 1 To PauseTime / 50
Threading.Thread.Sleep(50)
Application.DoEvents()
Next
End Sub
[/php]
Now you can use sleep() to pause your application without hurting the thread or effecting the macro.
[php]
SendKeys.Send("1")
sleep(100)
SendKeys.Send("2")
Sleep (100)
SendKeys.Send("3")
Sleep(100)
SendKeys.Send("4")
Sleep (100)
[/php]
I would also suggest a higher interval, maybe 300, 100 is 1/10 a second, it's a rather quick action, that means you will roate through this list twice in a second.
best bet is to use a slightly higher interval which would also resolve some of the issues.
let me know id this helps.
Thanks
When Sleeping with threading or using Sharks API example to simulate sleep
[php]
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
[/php]
You are (for system.threading.sleep) causing not only your application to pause, but you are pausing the whole thread, you can work with multi threading to avoid this, but it isn't necessary. When using the API you are effecting the TMR Macro, which again can cause your application to pause and therefor lag any other running process. The way the .net framework has accommodated for that is with DoEvents() this allows you to continue processes already cued in the thread and cue new processes into the thread which will allow smoother pauses, I wrote a small snippet in the snippet vault.
http://www.mpgh.net/forum/33-visual-...ets-vault.html
[php]
Private Sub Sleep(ByVal PauseTime As Double)
Dim Tind As Int16
For Tind = 1 To PauseTime / 50
Threading.Thread.Sleep(50)
Application.DoEvents()
Next
End Sub
[/php]
Now you can use sleep() to pause your application without hurting the thread or effecting the macro.
[php]
SendKeys.Send("1")
sleep(100)
SendKeys.Send("2")
Sleep (100)
SendKeys.Send("3")
Sleep(100)
SendKeys.Send("4")
Sleep (100)
[/php]
I would also suggest a higher interval, maybe 300, 100 is 1/10 a second, it's a rather quick action, that means you will roate through this list twice in a second.
best bet is to use a slightly higher interval which would also resolve some of the issues.
let me know id this helps.
Thanks

Hooray! Let's give a round of applause for NextGen 

This thread is closed for replies.



