/// <summary> /// Waits until the cT is cancelled. /// </summary> public static IEnumerator Spin(Action <Completion> done, ICancellee cT) { while (true) { if (cT.Cancelled) { break; } yield return(null); } done(cT.ToCompletion()); }
/// <summary> /// Waits for the given amount of time, but can be cancelled early by the cT. /// </summary> public static IEnumerator WaitFor(float time, Action <Completion> done, ICancellee cT, Func <float> dT) { for (float elapsed = 0; elapsed < time; elapsed += dT()) { if (cT.Cancelled) { break; } yield return(null); } done(cT.ToCompletion()); }