Пример #1
0
            public AsyncOperationAwaiter(AsyncOperationHandle <T> asyncOperation)
            {
                _status = asyncOperation.IsDone ? AwaiterStatus.Succeeded : AwaiterStatus.Pending;
                _result = asyncOperation.IsDone ? asyncOperation.Result : default;

                _asyncOperation = _status.IsCompleted() ? default : asyncOperation;
                                  _continuationAction = null;
            }
            public AsyncOperationHandleConfiguredAwaiter(AsyncOperationHandle asyncOperationHandle, IProgress <float> progress, CancellationToken cancellationToken)
            {
                status = cancellationToken.IsCancellationRequested ? AwaiterStatus.Canceled
                    : asyncOperationHandle.IsDone ? AwaiterStatus.Succeeded
                    : AwaiterStatus.Pending;

                if (status.IsCompleted())
                {
                    return;
                }

                this.asyncOperationHandle = asyncOperationHandle;
                this.progress             = progress;
                this.cancellationToken    = cancellationToken;

                continuationAction = null;

                TaskTracker.TrackActiveTask(this, 2);
            }