Page 1 of 1
Delay() inside "While ProgramRunning..."-Loop?
Posted: Fri Apr 01, 2022 6:57 pm
by Lebostein
Should a delay be included here? I have the whole thing running in a thread....
Code: Select all
While ProgramRunning(programID)
; Delay() ???
If AvailableProgramOutput(programID)
output$ + ReadProgramString(programID) + #CRLF$
EndIf
Wend
Re: Delay() inside "While ProgramRunning..."-Loop?
Posted: Fri Apr 01, 2022 7:10 pm
by STARGĂ…TE
Yes, a Delay(0) is enough.
Code: Select all
While ProgramRunning(programID)
If AvailableProgramOutput(programID)
output$ + ReadProgramString(programID) + #CRLF$
Else
Delay(0)
EndIf
Wend
Re: Delay() inside "While ProgramRunning..."-Loop?
Posted: Fri Apr 01, 2022 7:40 pm
by jacdelad
Please ignore my ignorance, but what does a Delay(0) do?
Re: Delay() inside "While ProgramRunning..."-Loop?
Posted: Fri Apr 01, 2022 7:44 pm
by NicTheQuick
It instructs the scheduler of your operating system to use the CPU for an other thread/process until the scheduler decides to give your thread attention again.
Re: Delay() inside "While ProgramRunning..."-Loop?
Posted: Fri Apr 01, 2022 11:01 pm
by Crusiatus Black
NicTheQuick wrote: Fri Apr 01, 2022 7:44 pm
It instructs the scheduler of your operating system to use the CPU for an other thread/process until the scheduler decides to give your thread attention again.
Is that not only true for Windows?