public static UniTask <UnityWebRequest> WithCancellation(this UnityWebRequestAsyncOperation asyncOperation, CancellationToken cancellationToken)
 {
     Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation));
     if (asyncOperation.isDone)
     {
         return(UniTask.FromResult(asyncOperation.webRequest));
     }
     return(new UniTask <UnityWebRequest>(UnityWebRequestAsyncOperationConfiguredSource.Create(asyncOperation, PlayerLoopTiming.Update, null, cancellationToken, out var token), token));
 }
 public static UniTask <UnityWebRequest> ToUniTask(this UnityWebRequestAsyncOperation asyncOperation, IProgress <float> progress = null, PlayerLoopTiming timing = PlayerLoopTiming.Update, CancellationToken cancellationToken = default(CancellationToken))
 {
     Error.ThrowArgumentNullException(asyncOperation, nameof(asyncOperation));
     if (asyncOperation.isDone)
     {
         return(UniTask.FromResult(asyncOperation.webRequest));
     }
     return(new UniTask <UnityWebRequest>(UnityWebRequestAsyncOperationConfiguredSource.Create(asyncOperation, timing, progress, cancellationToken, out var token), token));
 }
            public static IUniTaskSource <UnityWebRequest> Create(UnityWebRequestAsyncOperation asyncOperation, PlayerLoopTiming timing, IProgress <float> progress, CancellationToken cancellationToken, out short token)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return(AutoResetUniTaskCompletionSource <UnityWebRequest> .CreateFromCanceled(cancellationToken, out token));
                }

                if (!pool.TryPop(out var result))
                {
                    result = new UnityWebRequestAsyncOperationConfiguredSource();
                }

                result.asyncOperation    = asyncOperation;
                result.progress          = progress;
                result.cancellationToken = cancellationToken;

                TaskTracker.TrackActiveTask(result, 3);

                PlayerLoopHelper.AddAction(timing, result);

                token = result.core.Version;
                return(result);
            }