diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-11-02 22:51:38 -0800 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-11-02 22:51:38 -0800 |
commit | 8cc2fa50f05f4b3cc30856b40336e9fd8ee85e33 (patch) | |
tree | 2da217f1043b0b286bbe5d1f42a158b06c7267e5 | |
parent | fe66a05013df51312dec9074eed7915ba3b2da8a (diff) | |
download | DotNetOpenAuth-8cc2fa50f05f4b3cc30856b40336e9fd8ee85e33.zip DotNetOpenAuth-8cc2fa50f05f4b3cc30856b40336e9fd8ee85e33.tar.gz DotNetOpenAuth-8cc2fa50f05f4b3cc30856b40336e9fd8ee85e33.tar.bz2 |
Improved threading of WPF sample.
-rw-r--r-- | samples/ConsumerWpf/MainWindow.xaml | 2 | ||||
-rw-r--r-- | samples/ConsumerWpf/MainWindow.xaml.cs | 15 |
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) {
|