summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/ConsumerWpf/MainWindow.xaml2
-rw-r--r--samples/ConsumerWpf/MainWindow.xaml.cs15
2 files changed, 14 insertions, 3 deletions
diff --git a/samples/ConsumerWpf/MainWindow.xaml b/samples/ConsumerWpf/MainWindow.xaml
index 1c8fa84..3434b9b 100644
--- a/samples/ConsumerWpf/MainWindow.xaml
+++ b/samples/ConsumerWpf/MainWindow.xaml
@@ -16,7 +16,7 @@
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="3">
<Button Name="beginAuthorizationButton" Click="beginAuthorizationButton_Click">Start authorize</Button>
- <Button Name="completeAuthorizationButton" Margin="5,0,0,0" Click="completeAuthorizationButton_Click">Complete authorization</Button>
+ <Button Name="completeAuthorizationButton" Margin="5,0,0,0" Click="completeAuthorizationButton_Click" IsEnabled="false">Complete authorization</Button>
</StackPanel>
<Label>Consumer Key</Label>
<TextBox Grid.Column="1" Name="consumerKeyBox"/>
diff --git a/samples/ConsumerWpf/MainWindow.xaml.cs b/samples/ConsumerWpf/MainWindow.xaml.cs
index 37dc288..dc805ce 100644
--- a/samples/ConsumerWpf/MainWindow.xaml.cs
+++ b/samples/ConsumerWpf/MainWindow.xaml.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+ using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@@ -37,8 +38,18 @@
this.tokenManager.ConsumerSecret = consumerSecretBox.Text;
this.google.ConsumerKey = consumerKeyBox.Text;
- Uri browserAuthorizationLocation = GoogleConsumer.RequestAuthorization(this.google, GoogleConsumer.Applications.Contacts, out this.requestToken);
- System.Diagnostics.Process.Start(browserAuthorizationLocation.AbsoluteUri);
+ Cursor original = this.Cursor;
+ this.Cursor = Cursors.Wait;
+ beginAuthorizationButton.IsEnabled = false;
+ ThreadPool.QueueUserWorkItem(delegate(object state) {
+ Uri browserAuthorizationLocation = GoogleConsumer.RequestAuthorization(this.google, GoogleConsumer.Applications.Contacts, out this.requestToken);
+ System.Diagnostics.Process.Start(browserAuthorizationLocation.AbsoluteUri);
+ this.Dispatcher.BeginInvoke(new Action(() => {
+ this.Cursor = original;
+ beginAuthorizationButton.IsEnabled = true;
+ completeAuthorizationButton.IsEnabled = true;
+ }));
+ });
}
private void completeAuthorizationButton_Click(object sender, RoutedEventArgs e) {