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
-
objectAsyncWait
Methods
- Seconds(float)
Waits
secondsof real time. Prefer this overTask.Delayin 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
conditionholds 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
taskcompletes ortimeoutSecondsof real time pass. Returns whether the task completed. Never blocks a thread, so it is safe everywhere.