Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

DelayMBS(time as Double)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin Yes Yes Yes Yes No
Function: Stopps the application for the given time.
Example:
DelayMBS 1.5 // wait one and a half seconds
Notes:
The application should take nearly 0% CPU Power till time has gone.
If you need more options like blocking other RB threads, check the DelayMBS method with mode parameter.

Another example from Kirk Clendinning:

Property: lastupdate as Integer

Sub YieldProcessorTime(periodticks as Integer, widthmilliseconds as Integer)
// use the Monkeybread Software delay to yeild time for a screen update
// every period*ticks for a pulse width of width milliseconds

if ticks>lastupdate+periodTicks then
delayMBS widthmilliseconds/1000
lastupdate=ticks
end if

exception err
ExceptionReport(err, "Utils:Methods:YieldProcessorTime")
end sub

YieldProcessorTime(15, 20) gives me a delay of 20ms every 250ms. But,
since the delayMBS yields time more efficiently than using a RB thread, this turns out to be a much more effective way to update progress bars etc.
I don't need the delay per se, but since RB still hasn't written a good yield function (that I know of) your delayMSB works instead.

Please use optional mode flags with DelayDontWaitNextEvent when using on thread.

Using DelayMBS on Web Applications can cause problems as the server is paused than for all clients, a really bad thing.

See also:

Some examples using this method:

Feedback, Comments & Corrections

DelayMBS(time as Double, mode as Integer)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 6.4 Yes Yes Yes Yes No
Function: Stopps the application for the given time.
Example:
DelayMBS 1.5, 0 // wait one and a half seconds
Notes:
Like DelayMBS with one parameter but additional mode parameter:

combine the following constants:

const DelayDontMPYield = 1// Don't give additional time for other OS threads
const DelayDontRBYield = 2// Don't give REALbasic time for other REALbasic threads
const DelayDontThreadYield = 4// Don't give addition time for other OS threads
const DelayDontQuickTimeYield = 8// Don't give time for QuickTime Movieplayer
const DelayDontWait = 16// Don't give CPU time for other OS threads
const DelayDontWaitNextEvent = 32// Don't give CPU time to handle events on Mac OS X to avoid beachball cursor
const DelayDontSleep = 64// Don't give CPU time for other OS threads (Windows)

Using DelayDontWaitNextEvent may show the beach ball cursor, but will have the OpenDocument event working as other AppleEvents. Please use DelayDontWaitNextEvent option for running on threads.

Using DelayMBS on Web Applications can cause problems as the server is paused than for all clients, a really bad thing.

See also:

Some examples using this method:

Feedback, Comments & Corrections

SleepMBS(time as Double)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method System MBS Util Plugin 11.3 Yes Yes Yes Yes No
Function: Sleeps the current thread for the given time in seconds.
Example:
dim sock as TCPSocket // some socket
dim done as Boolean // some global property

do

SleepMBS(0.1) // 100 ms
sock.poll

loop until done
Notes:
Sleep does not yield CPU time to other functions, so you really sleep the whole process.
Useful for console projects which sleep for a few milliseconds in a loop polling a socket.

If you need to give CPU time to socket, other threads or for quicktime movie playback, please use DelayMBS.

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Util Plugin.





Links
MBS Xojo tutorial videos