Last active
December 11, 2015 07:07
-
-
Save ikhanhmai/dff88bb0819feab847f3 to your computer and use it in GitHub Desktop.
Unity - Parse Callback in Main thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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