From Sprezz Towers

Notes from the workshop.

Technical discoveries, field notes, unlikely bugs and the occasional opinion.

Building a better Delay() - Part 1

In this post we’re going to turn our attention to an old Arev subroutine called Delay() that can still be used in OpenInsight. It’s a simple function and is designed to halt a Basic+ program for a specified number of seconds before continuing again (full details can be found in the OpenInsight on-line help). However, while Delay() made the transition to the Windows world, it still behaves in a fashion befitting its DOS/Arev heritage - i.e. it expects to run in a single, non-multitasking environment. Internally it simply sits in a tight until loop until the nominated interval has passed after which it returns. This is all well and good but on a modern OS this steals virtually all the CPU time, which is silly when you consider that the actual intent is to simply “do nothing”! So, assuming that we actually want to introduce a delay of some sort into a program, what we really need to do is only put the actual OpenEngine thread (i.e. the thread that executes your Basic+ code) into a sta...

Read article →