Skip to content

Commit

Permalink
Fix compilation error with UniTask
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Jun 16, 2024
1 parent 5ec983c commit 21dd1bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Threading;
#if UNITY_2023_1_OR_NEWER
using UnityEngine;
#elif VCONTAINER_UNITASK_INTEGRATION
#if VCONTAINER_UNITASK_INTEGRATION
using Awaitable = Cysharp.Threading.Tasks.UniTask;
#elif UNITY_2023_1_OR_NEWER
using UnityEngine;
#else
using Awaitable = System.Threading.Tasks.Task;
#endif
Expand Down
29 changes: 14 additions & 15 deletions VContainer/Assets/VContainer/Runtime/Unity/PlayerLoopItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,30 +311,29 @@ public bool MoveNext()
#if VCONTAINER_UNITASK_INTEGRATION
var task = x.StartAsync(cts.Token);
if (exceptionHandler != null)
{
task.Forget(ex => exceptionHandler.Publish(ex));
}
else
{
task.Forget();
}
#else
InvokeStartAsync(x);
try
{
var task = x.StartAsync(cts.Token);
_ = task.Forget(exceptionHandler);
}
catch (Exception ex)
{
if (exceptionHandler == null) throw;
exceptionHandler.Publish(ex);
}
#endif
}
return false;
}

private void InvokeStartAsync(IAsyncStartable x)
{
try
{
var task = x.StartAsync(cts.Token);
_ = task.Forget(exceptionHandler);
}
catch (Exception ex)
{
if (exceptionHandler == null) throw;
exceptionHandler.Publish(ex);
}
}

public void Dispose()
{
lock (entries)
Expand Down

0 comments on commit 21dd1bb

Please sign in to comment.