more strict handle cancel timing on asyncOperation.WithCancellation()

master
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);
}
}
@ -420,6 +426,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(asyncOperation.asset);
}
}
@ -714,6 +726,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(asyncOperation.asset);
}
}
@ -1008,6 +1026,12 @@ namespace Cysharp.Threading.Tasks
else
{
completed = true;
if (cancellationToken.IsCancellationRequested)
{
core.TrySetCanceled(cancellationToken);
return;
}
core.TrySetResult(asyncOperation.assetBundle);
}
}
@ -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())
{

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())