fix Forget when source is already completed and source is manualy optimized task source, does not work correctly

master
neuecc 2020-09-22 09:54:05 +09:00
parent 346b1e0a6b
commit 8537ddf8a6
1 changed files with 30 additions and 26 deletions

View File

@ -561,7 +561,8 @@ namespace Cysharp.Threading.Tasks
UniTaskScheduler.PublishUnobservedTaskException(ex); UniTaskScheduler.PublishUnobservedTaskException(ex);
} }
} }
else
{
awaiter.SourceOnCompleted(state => awaiter.SourceOnCompleted(state =>
{ {
using (var t = (StateTuple<UniTask.Awaiter>)state) using (var t = (StateTuple<UniTask.Awaiter>)state)
@ -577,6 +578,7 @@ namespace Cysharp.Threading.Tasks
} }
}, StateTuple.Create(awaiter)); }, StateTuple.Create(awaiter));
} }
}
public static void Forget(this UniTask task, Action<Exception> exceptionHandler, bool handleExceptionOnMainThread = true) public static void Forget(this UniTask task, Action<Exception> exceptionHandler, bool handleExceptionOnMainThread = true)
{ {
@ -629,7 +631,8 @@ namespace Cysharp.Threading.Tasks
UniTaskScheduler.PublishUnobservedTaskException(ex); UniTaskScheduler.PublishUnobservedTaskException(ex);
} }
} }
else
{
awaiter.SourceOnCompleted(state => awaiter.SourceOnCompleted(state =>
{ {
using (var t = (StateTuple<UniTask<T>.Awaiter>)state) using (var t = (StateTuple<UniTask<T>.Awaiter>)state)
@ -645,6 +648,7 @@ namespace Cysharp.Threading.Tasks
} }
}, StateTuple.Create(awaiter)); }, StateTuple.Create(awaiter));
} }
}
public static void Forget<T>(this UniTask<T> task, Action<Exception> exceptionHandler, bool handleExceptionOnMainThread = true) public static void Forget<T>(this UniTask<T> task, Action<Exception> exceptionHandler, bool handleExceptionOnMainThread = true)
{ {