Accept GetStatus calling multiple times

master
piti6 2020-12-17 12:31:43 +09:00
parent 3115efb672
commit fba6942d5f
1 changed files with 10 additions and 6 deletions

View File

@ -341,10 +341,12 @@ namespace Cysharp.Threading.Tasks
public UniTaskStatus GetStatus(short token)
{
var f = Interlocked.Exchange(ref factory, null);
if (f == null) throw new InvalidOperationException("Can't call twice.");
if (f != null)
{
task = f();
awaiter = task.GetAwaiter();
}
return task.Status;
}
@ -383,10 +385,12 @@ namespace Cysharp.Threading.Tasks
public UniTaskStatus GetStatus(short token)
{
var f = Interlocked.Exchange(ref factory, null);
if (f == null) throw new InvalidOperationException("Can't call twice.");
if (f != null)
{
task = f();
awaiter = task.GetAwaiter();
}
return task.Status;
}