Skip to content

Commit 37d8f4f

Browse files
committed
C# 8 #624
1 parent e4082ec commit 37d8f4f

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WhenEach.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public WhenEachResult(T result)
3939
public WhenEachResult(Exception exception)
4040
{
4141
if (exception == null) throw new ArgumentNullException(nameof(exception));
42-
this.Result = default!;
42+
this.Result = default;
4343
this.Exception = exception;
4444
}
4545

@@ -144,24 +144,24 @@ static void ConsumeAll(Enumerator self, UniTask<T>[] array, int length)
144144
{
145145
RunWhenEachTask(self, array[i], length).Forget();
146146
}
147+
}
147148

148-
static async UniTaskVoid RunWhenEachTask(Enumerator self, UniTask<T> task, int length)
149+
static async UniTaskVoid RunWhenEachTask(Enumerator self, UniTask<T> task, int length)
150+
{
151+
try
149152
{
150-
try
151-
{
152-
var result = await task;
153-
self.channel.Writer.TryWrite(new WhenEachResult<T>(result));
154-
}
155-
catch (Exception ex)
156-
{
157-
self.channel.Writer.TryWrite(new WhenEachResult<T>(ex));
158-
}
153+
var result = await task;
154+
self.channel.Writer.TryWrite(new WhenEachResult<T>(result));
155+
}
156+
catch (Exception ex)
157+
{
158+
self.channel.Writer.TryWrite(new WhenEachResult<T>(ex));
159+
}
159160

160-
if (Interlocked.Increment(ref self.completeCount) == length)
161-
{
162-
self.state = WhenEachState.Completed;
163-
self.channel.Writer.TryComplete();
164-
}
161+
if (Interlocked.Increment(ref self.completeCount) == length)
162+
{
163+
self.state = WhenEachState.Completed;
164+
self.channel.Writer.TryComplete();
165165
}
166166
}
167167

src/UniTask/Assets/Scenes/SandboxMain.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using UnityEngine.Rendering;
1919
using System.IO;
2020
using System.Linq.Expressions;
21+
using UnityEngine.Events;
2122

2223

2324

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

174175

175-
176+
176177

177178

178179
// var tako = await foo;
179180

180-
181181

182+
//UnityAction action;
183+
182184

183185
return 10;
184186
}

0 commit comments

Comments
 (0)