Sign in to follow this  
Followers 0
cueclub

tmer and sleep question

5 posts in this topic

Okay,

I am aware that when a program sleeps, it sleeps. nothing else for it to do. But what of with the sleeps I add some time stamps.

sleep would start at 10 min, <time stamp>, run for a min < time stamp> run next function < time stamp> run run that function and sleep for 3 min < time stamp>

then next function. And when that function is done < time stamp> again.

so then I could calculate the remaining time. using the time stamps. and just finish the initial function sleep.

Sorry if it is not making any sense, I haven had my coffee yet.

so it would look something like this.

while 1
func run()
do stuff
timestamp1
nextfunc()
endfunc

func2()
do stuff
time stamp2
next func()
endfunc

func3()
do stuff
time stamp
endfunc

$ts = Timestamp1 - timestamp2 - timestamp3
sleep($ts)
wend

something like that.

Just need pointed in the right direction. Thanks in advance

Share this post


Link to post
Share on other sites



I think not ...

Sleeps since the start after the execution of the function ...

I think you should add the Sleep + times the run time of all functions.

But...W8 for + replyes..Here they give solution to everything :(


I read ... I update ... I learn ...

Share this post


Link to post
Share on other sites

Looks prett close

I would do

$slp=max amount of time you want to sleep

While 1
func1()
func2()
func3()
$ts=$slp-$time1-$time2-$time3
Sleep($ts)
Wend

Func func1()
do stuff
$time1=your timestamp
EndFunc

Func func2()
do stuff
$time2=your timestamp
EndFunc

Func func3()
do stuff
$time3=your timestamp
EndFunc

You might have to do some time conversion depending if you use @Hour and @Min for your timestamp or TimerInit().


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

thx Fi0da

ok I didnt even think about doing it like this

$slp=max amount of time you want to sleep

While 1
func1()
func2()
func3()
$ts=$slp-$time1-$time2-$time3
Sleep($ts)
Wend

So If I do that, Instead of a timerint() I could use a Now() perhaps. Cant remember off the top of my head if it has min/sec or not.

I will mess with it. Thanks you both for the reply

Cue

Share this post


Link to post
Share on other sites

cueclub,

I would do it this way (if I have understood you correctly) :( :

; Start our 10 min timer
$iBegin_10 = TimerInit()
ConsoleWrite(@SEC & @CRLF)  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Run first function
Func_1()

; Wait for 1 min
$iBegin_1 = TimerInit()
Do
    Sleep(10)
Until TimerDiff($iBegin_1) > 1000 ; 1*60*1000
ConsoleWrite(@SEC & @CRLF)  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Run Second function
Func_2()

; Wait for 3 mins
$iBegin_3 = TimerInit()
Do
    Sleep(10)
Until TimerDiff($iBegin_3) > 3000 ; 3 * 60 * 1000
ConsoleWrite(@SEC & @CRLF)  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Run Third function
Func_3()

; Now wait until the 10 minutes are up
Do
    Sleep(10)
Until TimerDiff($iBegin_10) > 10000 ; 10 * 60 * 1000
ConsoleWrite(@SEC & @CRLF)  ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; And here we are 10 minutes later

Func Func_1()
    ; do stuff()
EndFunc

Func Func_2()
    ; do stuff()
EndFunc

Func Func_3()
    ; do stuff()
EndFunc

At the moment I have set it to run for seconds rather than minutes so you can see it working with the ConsoleWrite lines. Just delete them and replace the values in the TimerDiff lines when you want it to run for the full time.

If this is not want you want - drink some coffee and explain again! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0