Table of Contents

Class AsyncWait

Namespace
GrindFest
Assembly
GrindFest.dll

Player-loop-driven waits — the platform-correct replacement for blocking on a task.

Why this exists: on WebGL there are no threads, so task.Wait(), task.Result and GetAwaiter().GetResult() cannot ever complete there. They are not a slow path, they are a hang — which is how DungeonGenerator froze a browser and how OnApplicationQuit could stop a build from exiting. Everything below is driven by Unity's own player loop (NextFrameAsync(CancellationToken)), so it completes wherever the player runs.

Deliberately not built on Task.Delay: a delay is a timer, and whether the runtime can fire one without threads is exactly the platform question this type exists to avoid.

public static class AsyncWait
Inheritance
object
AsyncWait

Methods

Seconds(float)

Waits seconds of real time. Prefer this over Task.Delay in player code: same intent, no timer, and it advances while the game is paused for the editor (real time, not scaled time).

Until(Func<bool>, float)

Yields frames until condition holds or the timeout elapses. The frame cadence is the point: it works with no threads, no timers and no synchronisation context.

UntilCompletedOrTimeout(Task, float)

Yields frames until task completes or timeoutSeconds of real time pass. Returns whether the task completed. Never blocks a thread, so it is safe everywhere.