/// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary> public static async UniTask <T> Run <T>(Func <T> func, bool configureAwait = true) { await UniTask.SwitchToThreadPool(); if (configureAwait) { try { return(func()); } finally { await UniTask.Yield(); } } else { return(func()); } }
/// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary> public static async UniTask Run(Action action, bool configureAwait = true) { await UniTask.SwitchToThreadPool(); if (configureAwait) { try { action(); } finally { await UniTask.Yield(); } } else { action(); } }
/// <summary>Run action on the threadPool and return to main thread if configureAwait = true.</summary> public static async UniTask Run(Func <object, UniTask> action, object state, bool configureAwait = true) { await UniTask.SwitchToThreadPool(); if (configureAwait) { try { await action(state); } finally { await UniTask.Yield(); } } else { await action(state); } }
public UniTask ToUniTask() { return(UniTask.Yield(timing, CancellationToken.None)); }
/// <summary> /// Same as UniTask.Yield(PlayerLoopTiming.FixedUpdate, cancellationToken). /// </summary> public static UniTask WaitForFixedUpdate(CancellationToken cancellationToken) { return(UniTask.Yield(PlayerLoopTiming.FixedUpdate, cancellationToken)); }
/// <summary> /// Same as UniTask.Yield(PlayerLoopTiming.FixedUpdate). /// </summary> public static YieldAwaitable WaitForFixedUpdate() { return(UniTask.Yield(PlayerLoopTiming.FixedUpdate)); }
/// <summary> /// Same as UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate, cancellationToken). /// </summary> public static UniTask WaitForEndOfFrame(CancellationToken cancellationToken) { return(UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate, cancellationToken)); }
/// <summary> /// Same as UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate). /// </summary> public static YieldAwaitable WaitForEndOfFrame() { return(UniTask.Yield(PlayerLoopTiming.LastPostLateUpdate)); }
public static async UniTask WaitAsync(this JobHandle jobHandle, PlayerLoopTiming waitTiming) { await UniTask.Yield(waitTiming); jobHandle.Complete(); }