xamarin/Xamarin.Auth — pull request #24 by gaearon (2013-06-04 19:15:01+00:00)
Title: Preserve synchronization context because OnRetrievedAccountProperties uses it

`OnRetrievedAccountProperties` tries to pass along a synchronization context:

if (getUsernameAsync != null) {
getUsernameAsync (accountProperties).ContinueWith (task => {
// ...
}, TaskScheduler.FromCurrentSynchronizationContext ());

However, `OnRetrievedAccountProperties` is also called from a continuation inside `OnRedirectPageLoaded` that doesn't preserve the context:

RequestAccessTokenAsync (code).ContinueWith (task => {
if (task.IsFaulted) {
OnError (task.Exception);
} else {
// Ouch!
OnRetrievedAccountProperties (task.Result);
}
});

This pull requests adds `TaskScheduler.FromCurrentSynchronizationContext ()` to this continuation so the code doesn't crash.