[C#] Load level after login async (Parse.com)

I am a Unity beginner and I am getting stuck on a really simple thing.
I want to login using the Parse SDK and if the login returns true I want to load the menu scene.
I have a login screen with a Login button and onclick I have the following function

public void LoginParse ()
    {
        GameObject usernamebox = GameObject.Find("UsernameBox");
        InputField usernamefield = usernamebox.GetComponent<InputField>();
        GameObject passwordbox = GameObject.Find("PasswordBox");
        InputField passwordfield = passwordbox.GetComponent<InputField>();
        ParseUser.LogOut();
        AuthenticateParse (usernamefield.text, passwordfield.text);
//if there is whatever piece of code here, this makes Unity freeze   
// I would like to check if the task of Authentication is finished and if so check the current user. 
//If true then I would like to run Application.LoadLevel ("scenemenu");

     }
       
public void AuthenticateParse(string usern,string pass)
    {
        ParseUser user = null;
        ParseUser.LogInAsync(usern, pass).ContinueWith (t =>
                                                                                    {
           
            if (t.IsFaulted || t.IsCanceled) {
                //exceptions
            } else {
                user = t.Result;
            }
        });
    }

Whenever I add code after the LoginAsync call unity gets frozen and I need to end it with the task manager. What am I missing? Thank you!

I have a same problem. Did you find the solution?

The Task.CountinueWith format doesn’t really work in Unity. ContinueWith runs on the ASync thread created for the task, and so can’t access the unity API. A better method is to use a coroutine.

var loginTask = ParseUser.LoginAsync(...);
while (!loginTask.isDone) yield return null;
Application.LoadLevel(...);

Yes, I found the solution. Actually in Unity the Async operations are put into coroutines, but how do we handle if the function has a ContinueWith? In order to yield for the second part of the Async call we need to put a flag and a while statement to check the flag. In my case the flag is the bool current, and the code looks like this

public void AuthenticateParse(string usern,string pass)
    {
        ParseUser user = null;
        ParseUser.LogInAsync(usern, pass).ContinueWith (t =>
    {
            print ("I sent data");
            if (t.IsFaulted || t.IsCanceled) {
                print ("We could not log you in"); //write exceptions!!!
            } else {
                user = t.Result;
                current = true;

            }
        });
    }

then, to yield for the bool, we need to insert the function into a coroutine for the use of the while cycle, this way:

public bool current = false;

public IEnumerator MyCoroutineLogin ()
{
AuthenticateParse(myuser, mypass);
while (!current){
yield return null;
}
//do whatever you want after login here
}

In case, somewhere else we can just start this coroutine and always check for the flag, for example in the Start() function.