Search code examples
c#parse-platformunity-game-enginefacebook-canvasthread-synchronization

synchronizationLockException object is not synchronised - parse login issue


I am getting this synchronizationLockException in facebook canvas app.synchronizationLockException screenshot my issue is something similer to this. I have implemented facebook sdk also which is working properly but getting synchronizationLockException when trying to login into parse from this chunk of code.

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);
        }
    });

}

this code has been taken from source code


Solution

  • the async thread and main thread might be using the variable at the same time .

    try this instead

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