mirror of https://github.com/Cysharp/UniTask
C# 8 #624
parent
e4082ecd75
commit
37d8f4f48e
|
@ -39,7 +39,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
public WhenEachResult(Exception exception)
|
public WhenEachResult(Exception exception)
|
||||||
{
|
{
|
||||||
if (exception == null) throw new ArgumentNullException(nameof(exception));
|
if (exception == null) throw new ArgumentNullException(nameof(exception));
|
||||||
this.Result = default!;
|
this.Result = default;
|
||||||
this.Exception = exception;
|
this.Exception = exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,24 +144,24 @@ namespace Cysharp.Threading.Tasks
|
||||||
{
|
{
|
||||||
RunWhenEachTask(self, array[i], length).Forget();
|
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));
|
||||||
var result = await task;
|
}
|
||||||
self.channel.Writer.TryWrite(new WhenEachResult<T>(result));
|
catch (Exception ex)
|
||||||
}
|
{
|
||||||
catch (Exception ex)
|
self.channel.Writer.TryWrite(new WhenEachResult<T>(ex));
|
||||||
{
|
}
|
||||||
self.channel.Writer.TryWrite(new WhenEachResult<T>(ex));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Interlocked.Increment(ref self.completeCount) == length)
|
if (Interlocked.Increment(ref self.completeCount) == length)
|
||||||
{
|
{
|
||||||
self.state = WhenEachState.Completed;
|
self.state = WhenEachState.Completed;
|
||||||
self.channel.Writer.TryComplete();
|
self.channel.Writer.TryComplete();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,6 +179,7 @@ public class SandboxMain : MonoBehaviour
|
||||||
// var tako = await foo;
|
// var tako = await foo;
|
||||||
|
|
||||||
|
|
||||||
|
//UnityAction action;
|
||||||
|
|
||||||
|
|
||||||
return 10;
|
return 10;
|
||||||
|
|
Loading…
Reference in New Issue