synchronizationLockException 对象未同步 - 解析登录问题

synchronizationLockException object is not synchronised - parse login issue

我在 facebook canvas 应用程序中收到此 synchronizationLockException。 我的问题类似于 this。我也实现了 facebook sdk,它工作正常但在尝试从这段代码登录到解析时得到 synchronizationLockException。

IEnumerator  OnLoggedIn()                                                                          
{                  

    Debug.Log("Logged in. ID: " + FB.UserId);                                            
    System.Threading.Tasks.Task<ParseUser> logInTask = ParseFacebookUtils.LogInAsync (FB.UserId, FB.AccessToken, FB.AccessTokenExpiresAt);
    while(!logInTask.IsCompleted) 
        yield return null;
    logInTask.ContinueWith (t => {
        if (t.IsFaulted || t.IsCanceled) {
            Debug.Log ("Parse Login failed");
            Debug.Log ("t.Exception=" + t.Exception);
            foreach (Exception e in logInTask.Exception.InnerExceptions) {
                ParseException parseException = (ParseException)e;
                Debug.Log ("Error message " + parseException.Message);
                Debug.Log ("Error code: " + parseException.Code);
            }
        } else {
            ParseUser userFB = t.Result;
            Debug.Log("--------------------------------------------------------------------------userfb:"+userFB.ObjectId);
            objectId=userFB.ObjectId;
            FB.API("/me", HttpMethod.GET, FBAPICallback);
        }
    });

}

此代码取自 source code

异步线程和主线程可能同时使用该变量。

试试这个

http://answers.unity3d.com/questions/438578/variable-access-simulateneously.html