Handling timing, delays and repetition in WebCore

I'm curious if anything has been written that addresses the general topic of how to deal with timing, delays, and time-based triggering of actions when working in WebCore?

Everything in the UI is asynchronous, and a lot of work has been done to simplify how to deal with arbitrary timing gaps here and there.

But suppose you want to click a button and have something run for 5 seconds, then stop? Or you have something you want to trigger every second? Like playing a drum hit?

I've tried using a TTimer and it doesn't look very predictable. And Sleep( ) doesn't seem to behave entirely as expected.

The Web Audio API doesn't have any timers or timing stuff built into it because I guess they expect you to use whatever Javascript offers. Most actions just have Start and Stop methods on them; some have a Pause method as well.

TTimer and Sleep were written to work with Windows, even though they're fairly high-level.

I'm curious if there's a different way recommended to manage timing relationships within WebCore that's more tightly integrated with Javascript? Or should we be using Threads instead?

Did you consider using TWebTimer over TTimer? TWebTimer works for me.

Ahh, didn't think of that. Thanks!