public static (UniTask, CancellationTokenRegistration) ToUniTask(this CancellationToken cts) { if (cts.IsCancellationRequested) { return (UniTask.FromCanceled(cts), default(CancellationTokenRegistration)); } var promise = new UniTaskCompletionSource<AsyncUnit>(); return (promise.Task, cts.RegisterWithoutCaptureExecutionContext(cancellationTokenCallback, promise)); }
public static (UniTask, CancellationTokenRegistration) ToUniTask(this CancellationToken cts) { if (cts.IsCancellationRequested) { return(UniTask.FromCanceled(cts), default);