Non-Blocking Event Loop Asynchronous with App Interface

Hello,
I am trying to run an event loop that runs a SoundEffect after a set amount of milliseconds, that is interruptible through a variable change.

I originally tried a simple while loop like this:

    while true
        if m.canLoop = true
            exit while
        end if
        sleep(m.sleepTime)
        m.soundEffect.control = "play"
    end while

However, I realized that this loop blocked the App Interface, and I eventually got an Execution timeout.

Is there a loop that is able to be interrupted, and does not block the App Interface?

You want to use a RSG Timer control (see Timer). This will let you set a callback that gets called after a certain amount of time, and that time can be adjusted as needed.