void Update() { /* * Note, we only run one task each frame, * because it's easier that way and * it's good enought right now. */ Task task; if (!Tasks.CheckAndDequeue(out task)) { /* no task to run on the main thread, we are done */ return; } /* do the needful */ task(); }