当前位置: 首页>>代码示例>>C#>>正文


C# Task.OnSuccess方法代码示例

本文整理汇总了C#中Task.OnSuccess方法的典型用法代码示例。如果您正苦于以下问题:C# Task.OnSuccess方法的具体用法?C# Task.OnSuccess怎么用?C# Task.OnSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Task的用法示例。


在下文中一共展示了Task.OnSuccess方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpgradeToRevocableSessionAsync

    internal Task UpgradeToRevocableSessionAsync(Task toAwait, CancellationToken cancellationToken) {
      string sessionToken = SessionToken;

      return toAwait.OnSuccess(_ => {
        return ParseSession.UpgradeToRevocableSessionAsync(sessionToken, cancellationToken);
      }).Unwrap().OnSuccess(t => {
        return SetSessionTokenAsync(t.Result);
      }).Unwrap();
    }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:9,代码来源:ParseUser.cs

示例2: SaveAsync

 private Task SaveAsync(Task toAwait, IProgress<AVUploadProgressEventArgs> progress,
     CancellationToken cancellationToken)
 {
     lock (this.mutex)
     {
         string currentSessionToken = AVUser.CurrentSessionToken;
     }
     long position = this.dataStream.Position;
     return toAwait.OnSuccess<Task>(t => {
         Task task1 = null;
         lock (this.mutex)
         {
             if (!this.IsDirty)
             {
                 task1 = Task.FromResult<int>(0);
             }
             else
             {
                 string str = Guid.NewGuid().ToString();
                 str = string.Concat(str, Path.GetExtension(this.name));
                 task1 = this.GetQiniuToken(str, cancellationToken).ContinueWith(s => {
                     this.MergeFromJSON(s.Result.Item2);
                     return this.ResumableUploadToQiniu(progress, str, cancellationToken);
                 }, cancellationToken).Unwrap().ContinueWith<Task>(d => {
                     Task task = null;
                     task = (d.Result.Item1 == HttpStatusCode.OK ? Task.FromResult<int>(0) : this.DeleteAsync(cancellationToken));
                     return task;
                 }, cancellationToken).Unwrap();
             }
         }
         return task1;
     }).Unwrap().ContinueWith<Task>((Task t) => {
         if ((t.IsFaulted || t.IsCanceled) && this.dataStream.CanSeek)
         {
             this.dataStream.Seek(position, SeekOrigin.Begin);
         }
         return t;
     }, cancellationToken).Unwrap();
 }
开发者ID:higankanshi,项目名称:MSDevUnion.BingWallpaper,代码行数:39,代码来源:AVFile.cs

示例3: SignUpAsync

    internal Task SignUpAsync(Task toAwait, CancellationToken cancellationToken) {
      if (AuthData == null) {
        // TODO (hallucinogen): make an Extension of Task to create Task with exception/canceled.
        if (string.IsNullOrEmpty(Username)) {
          TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
          tcs.TrySetException(new InvalidOperationException("Cannot sign up user with an empty name."));
          return tcs.Task;
        }
        if (string.IsNullOrEmpty(Password)) {
          TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
          tcs.TrySetException(new InvalidOperationException("Cannot sign up user with an empty password."));
          return tcs.Task;
        }
      }
      if (!string.IsNullOrEmpty(ObjectId)) {
        TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
        tcs.TrySetException(new InvalidOperationException("Cannot sign up a user that already exists."));
        return tcs.Task;
      }

      IDictionary<string, IParseFieldOperation> currentOperations = StartSave();

      return toAwait.OnSuccess(_ => {
        return UserController.SignUpAsync(State, currentOperations, cancellationToken);
      }).Unwrap().ContinueWith(t => {
        if (t.IsFaulted || t.IsCanceled) {
          HandleFailedSave(currentOperations);
        } else {
          var serverState = t.Result;
          HandleSave(serverState);
        }
        return t;
      }).Unwrap().OnSuccess(_ => SaveCurrentUserAsync(this)).Unwrap();
    }
开发者ID:cnbcyln,项目名称:Parse-SDK-dotNET,代码行数:34,代码来源:ParseUser.cs

示例4: DeleteAsync

        internal Task DeleteAsync(Task toAwait, CancellationToken cancellationToken)
        {
            if (ObjectId == null)
            {
                return Task.FromResult(0);
            }

            string sessionToken = AVUser.CurrentSessionToken;

            return toAwait.OnSuccess(_ =>
            {
                return FileController.DeleteAsync(state, sessionToken, cancellationToken);
            }).Unwrap().OnSuccess(_ => { });
        }
开发者ID:wujun4code,项目名称:Parse-SDK-dotNET,代码行数:14,代码来源:AVFile.cs


注:本文中的Task.OnSuccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。