[Help] Sleep Function

Posts 1623 of 23 · Page 2 of 2
Quote Originally Posted by Shark23 View Post
^ That works but there isn't any delay.
Set the timers delay higher LOL
^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.
Quote Originally Posted by Shark23 View Post
^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
Code:
system.thread.threading.sleep(1000)
(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.
Quote Originally Posted by trevor206 View Post
Ok well if you want delay b4 each timer at the top of the timers starting
Code:
system.thread.threading.sleep(1000)
(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.
It's not even the part of playing CF. It's just sendkeys.

Example:

1 (wait 1 second)
.
2 (wait 1 second)
.
3 (wait 1 second)
.
4 (wait 1 second)
Quote Originally Posted by Alroundeath View Post


It's not even the part of playing CF. It's just sendkeys.

Example:

1 (wait 1 second)
.
2 (wait 1 second)
.
3 (wait 1 second)
.
4 (wait 1 second)
AHHH WHERES NEXTGEN YOU GUYS ARE HURTING MY BRAIN ON SUCH A SIMPLE THING.
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
Quote Originally Posted by NextGen1 View Post
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
Haha nextgen
Hooray! Let's give a round of applause for NextGen
Posts 1623 of 23 · Page 2 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?