function setTimeout

Supported only in the v8 engine. Introduced in Max v9.2.0.

Schedules a one-shot callback to run after a delay.

Backed by the Max scheduler; the returned handle is a numeric ID for use with clearTimeout().

export declare function setTimeout(
  callback: (...args: any[]) => void,
  delay?: number,
  ...args: any[]
): number;
NameTypeDescription
callback(...args: any[]) => voidthe function to run when the timer fires
optional delaynumberdelay in milliseconds before the callback runs (default 0)
argsany[]additional arguments forwarded to the callback
Return Valuenumbera numeric timer ID

Example

const id = setTimeout((name) => post("hello", name, "\n"), 250, "world");
// ...
clearTimeout(id);