c# - 如何在保存后立即检索 objectId

标签 c# multithreading unity3d parse-platform

我正在使用 Unity 和 Parse.com 进行游戏开发。我想弄清楚我在保存后立即检索了 objectId。我试过这个:

ParseObject myGame = new ParseObject("Games");
myGame["score"] = 223;
myGame["playerName"] = "Michael";
Task saveTask = myGame.SaveAsync().ContinueWith(t => {

    ParseObject theObject = t.Result;
    string newObjectId = theObject.objectId;

});

我在 t.Result 上收到一条错误消息:

Type `System.Threading.Tasks.Task' does not contain a definition for `Result' and no
extension method `Result' of type `System.Threading.Tasks.Task' could be found (are
you missing a using directive or an assembly reference?)

这可以通过这种方式或其他方式完成吗?

感谢任何帮助并提前致谢:-)

最佳答案

我在检索新创建的 ObjectId 时也遇到了问题。几个小时后(以及大量搜索)我能够让下面的代码工作:

    public static async Task<string> CreateNewGame()
    {
        string newObjectId = null;

        ParseObject myGame = new ParseObject("Games");
        myGame["score"] = 223;
        myGame["playerName"] = "Michael";

        await myGame.SaveAsync().ContinueWith(
              t =>
              {
                  newObjectId = myGame.ObjectId;
              });

        return newObjectId;
    }

关于c# - 如何在保存后立即检索 objectId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27248622/

相关文章:

c# - 添加轻量级渲染管道时对象图形困惑

C# Windows 窗体 ComboBox 数组代码

c# - 创建一个支持不同单位(摄氏度、华氏度、开尔文)的温度类

Java 线程 - 同步代码

java - 如何检查线程是否在IntelliJ中容纳监视器?

Java : Thread Questions

c# - StreamReader 中的子字符串错误

c# - 用于 Rolling Sky x 轴控制的统一触摸输入

c# - 无法在计算机 '.' 上打开 <MyService> 服务

c# - 如何在 C# 中使用字符串保存 MySQL 数据库中的文件路径