Skip to content

Instantly share code, notes, and snippets.

@ikhanhmai
Last active December 11, 2015 07:07
Show Gist options
  • Save ikhanhmai/dff88bb0819feab847f3 to your computer and use it in GitHub Desktop.
Save ikhanhmai/dff88bb0819feab847f3 to your computer and use it in GitHub Desktop.
Unity - Parse Callback in Main thread
System.Threading.Tasks.Task queryTask;
try {
queryTask = ParseObject.SaveAllAsync (rewards);
} catch {
queryTask = null;
}
if (queryTask != null) {
while (!queryTask.IsCompleted)
yield return null;
if (queryTask.IsFaulted || queryTask.IsCanceled) {
// Handle error
print ("isFault");
using (IEnumerator<System.Exception> enumerator = queryTask.Exception.InnerExceptions.GetEnumerator()) {
if (enumerator.MoveNext ()) {
ParseException error = (ParseException)enumerator.Current;
print ("error " + error.Message);
// error.Message will contain an error message
// error.Code will return "OtherCause"
}
}
} else {
// Handle success
print ("complete");
}
} else {
print ("cannot save to cloud!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment