Skip to content

Commit a19f812

Browse files
committed
Fix backwards continuation cancellation logic
See #1
1 parent 51d58b6 commit a19f812

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

UnityAsync/Assets/UnityAsync/Continuation.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,25 @@ public struct Continuation<T> : IContinuation, INotifyCompletion where T : IAwai
2222
CancellationToken cancellationToken;
2323

2424
/// <summary>
25-
/// Evaluate the encapsulated <see cref="UnityAsync.IAwaitInstruction"/> to determine whether the continuation
26-
/// is finished and can continue. Will evaluate to true if its owner is destroyed or its cancellation token has
27-
/// been cancelled.
25+
/// Evaluate the encapsulated <see cref="UnityAsync.IAwaitInstruction"/>. If the instruction is finished, the
26+
/// continuation delegate is invoked and the method returns <code>true</code>. If the owner is destroyed or a
27+
/// cancellation was requested, the method will return true and will not invoke the continuation delegate.
28+
/// Otherwise, the method will return false, meaning the <see cref="UnityAsync.IAwaitInstruction"/> is not yet
29+
/// finished.
2830
/// </summary>
29-
/// <returns></returns>
31+
/// <returns>
32+
/// <code>true</code> if the <see cref="UnityAsync.IAwaitInstruction"/> is finished or cancelled, otherwise
33+
/// false.
34+
/// </returns>
3035
public bool Evaluate()
3136
{
32-
if(!owner || cancellationToken.IsCancellationRequested || instruction.IsCompleted())
37+
if(!owner || cancellationToken.IsCancellationRequested)
38+
return true;
39+
40+
if(instruction.IsCompleted())
3341
{
3442
continuation();
43+
3544
return true;
3645
}
3746

0 commit comments

Comments
 (0)