diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/ContinuationQueue.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/ContinuationQueue.cs index 2ba5938..30bd737 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/ContinuationQueue.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/ContinuationQueue.cs @@ -9,7 +9,7 @@ namespace Cysharp.Threading.Tasks.Internal { const int MaxArrayLength = 0X7FEFFFFF; const int InitialSize = 16; - + readonly PlayerLoopTiming timing; SpinLock gate = new SpinLock(); @@ -173,7 +173,14 @@ namespace Cysharp.Threading.Tasks.Internal var action = actionList[i]; actionList[i] = null; - action(); + try + { + action(); + } + catch (Exception ex) + { + UnityEngine.Debug.LogException(ex); + } } { diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Threading.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Threading.cs index 8077f60..39cd70f 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Threading.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Threading.cs @@ -44,6 +44,14 @@ namespace Cysharp.Threading.Tasks return new ReturnToMainThread(timing); } + /// + /// Queue the action to PlayerLoop. + /// + public static void Post(Action action, PlayerLoopTiming timing = PlayerLoopTiming.Update) + { + PlayerLoopHelper.AddContinuation(timing, action); + } + #endif public static SwitchToThreadPoolAwaitable SwitchToThreadPool()