more strict handle cancel timing on asyncOperation.WithCancellation()

pull/121/head
neuecc 2020-07-16 05:36:21 +09:00
parent 9d3b7adc8e
commit c2824027d4
2 changed files with 41 additions and 5 deletions

View File

@ -134,6 +134,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(AsyncUnit.Default);
}
}
@ -160,7 +166,7 @@ namespace Cysharp.Threading.Tasks
}
public bool MoveNext()
{
{
if (completed)
{
TryReturn();
@ -420,6 +426,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(asyncOperation.asset);
}
}
@ -450,7 +462,7 @@ namespace Cysharp.Threading.Tasks
}
public bool MoveNext()
{
{
if (completed)
{
TryReturn();
@ -714,6 +726,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(asyncOperation.asset);
}
}
@ -744,7 +762,7 @@ namespace Cysharp.Threading.Tasks
}
public bool MoveNext()
{
{
if (completed)
{
TryReturn();
@ -1008,6 +1026,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(asyncOperation.assetBundle);
}
}
@ -1038,7 +1062,7 @@ namespace Cysharp.Threading.Tasks
}
public bool MoveNext()
{
{
if (completed)
{
TryReturn();
@ -1325,6 +1349,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
var result = asyncOperation.webRequest;
if (result.IsError())
{
@ -1363,7 +1393,7 @@ namespace Cysharp.Threading.Tasks
}
public bool MoveNext()
{
{
if (completed)
{
TryReturn();

View File

@ -205,6 +205,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
<# if(IsUnityWebRequest(t)) { #>
var result = asyncOperation.webRequest;
if (result.IsError())