Skip to content

Commit

Permalink
C# 8 #624
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Oct 3, 2024
1 parent e4082ec commit 37d8f4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WhenEach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public WhenEachResult(T result)
public WhenEachResult(Exception exception)
{
if (exception == null) throw new ArgumentNullException(nameof(exception));
this.Result = default!;
this.Result = default;
this.Exception = exception;
}

Expand Down Expand Up @@ -144,24 +144,24 @@ static void ConsumeAll(Enumerator self, UniTask<T>[] array, int length)
{
RunWhenEachTask(self, array[i], length).Forget();
}
}

static async UniTaskVoid RunWhenEachTask(Enumerator self, UniTask<T> task, int length)
static async UniTaskVoid RunWhenEachTask(Enumerator self, UniTask<T> task, int length)
{
try
{
try
{
var result = await task;
self.channel.Writer.TryWrite(new WhenEachResult<T>(result));
}
catch (Exception ex)
{
self.channel.Writer.TryWrite(new WhenEachResult<T>(ex));
}
var result = await task;
self.channel.Writer.TryWrite(new WhenEachResult<T>(result));
}
catch (Exception ex)
{
self.channel.Writer.TryWrite(new WhenEachResult<T>(ex));
}

if (Interlocked.Increment(ref self.completeCount) == length)
{
self.state = WhenEachState.Completed;
self.channel.Writer.TryComplete();
}
if (Interlocked.Increment(ref self.completeCount) == length)
{
self.state = WhenEachState.Completed;
self.channel.Writer.TryComplete();
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/UniTask/Assets/Scenes/SandboxMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using UnityEngine.Rendering;
using System.IO;
using System.Linq.Expressions;
using UnityEngine.Events;



Expand Down Expand Up @@ -172,13 +173,14 @@ async UniTask<int> FooAsync()
// var foo = InstantiateAsync<SandboxMain>(this).ToUniTask();





// var tako = await foo;



//UnityAction action;


return 10;
}
Expand Down

0 comments on commit 37d8f4f

Please sign in to comment.