I dont understand this programming syntax around Dispatcher.RunAsync
.
All I know is that I have to translate the following authentification module from Linq2Twitter working on WP8 to WP8.1.
async void Page_Loaded(object sender, RoutedEventArgs e)
{
pinAuth = new PinAuthorizer
{
// Get the ConsumerKey and ConsumerSecret for your app and load them here.
CredentialStore = new InMemoryCredentialStore
{
ConsumerKey = "",
ConsumerSecret = ""
},
// Note: GetPin isn't used here because we've broken the authorization
// process into two parts: begin and complete
GoToTwitterAuthorization = pageLink => Dispatcher.BeginInvoke(
() => OAuthWebBrowser.Navigate(new Uri(pageLink, UriKind.Absolute)))
};
await pinAuth.BeginAuthorizeAsync();
}
The problem is Dispatcher.BeginInvoke
I found the solution for the problem in here but I don't get it working with my programming skills.
I would also appreciate a link/video tutorial to this topic. I don't even know where to start learning about Dispatcher, Threading etc.
Cheers,
Chris
//Update
The following seems to work but I dont know how to retrieve the PIN value from this WebAuthenticationBroker
pinAuth = new PinAuthorizer
{
// Get the ConsumerKey and ConsumerSecret for your app and load them here.
CredentialStore = new InMemoryCredentialStore
{
ConsumerKey = "",
ConsumerSecret = ""
},
// Note: GetPin isn't used here because we've broken the authorization
// process into two parts: begin and complete
GoToTwitterAuthorization = async pageLink =>
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
() => { WebAuthenticationBroker.AuthenticateAndContinue(
new Uri(pageLink, UriKind.Absolute)); })
};
await pinAuth.BeginAuthorizeAsync();