AnnulusGames/LitMotion

[Proposal] Make await handle; to throw OperationCanceledException when MotionHandle.Cancel.

Akeit0 opened this issue · 2 comments

It is odd that await handle does not throw an exception when the MotionHandle itself is canceled, even though handle.ToUniTask(cts.Token) throws an exception on CancellationTokenSource cancellation.

public void OnMotionCanceled()
{
    if (cancellationToken.IsCancellationRequested)
    {
        canceled = true;
    }
    if (canceled)
    {
        core.TrySetCanceled(cancellationToken);
    }
    else
    {
        core.TrySetCanceled();
       // core.TrySetResult(AsyncUnit.Default);
    }
}

It is certainly more natural to cancel the await, so I changed the behavior to do so. (#23)