I am trying to manage the Live SDK login in the WP8 app and have problems with this code here:
this.authClient = new LiveAuthClient("client Id");
LiveLoginResult loginResult = await this.authClient.InitializeAsync(scopes);
This is the code from the sample that Microsoft provides (Sample). But authClient.InitializeAsync(scopes) is never returning, I don't get any exception either. MSDN states (LiveAuthClient.InitializeAsync()) that this method does not return a value on Windows Phone. I would like to use this.authClient.LoginAsync(scopes)
then in order to manage the login, and can't do it if the client is not initialized.
I predict that you are calling Task<T>.Result
or Task.Wait
further up your call stack, which will cause a deadlock (as I explain on my blog).
By default, await
will capture the "current context" (in this case, likely a UI context), and will use that context to resume the execution of the async
method. If you block the UI thread by calling Result
or Wait
on that task, then the async
method cannot complete because it's trying to complete on the blocked UI thread.