added samples
[windows-sources.git] / sdk / samples / WPFSamples / CrossThreadExceptionRaising_UIThread / csharp / secondaryuithreadwindow.xaml.cs
blob70e9be1e11c0fea55c65e86e243955d739290ad2
1 using System; // Exception, EventArgs
2 using System.Threading; // Thread
3 using System.Windows; // Window, RoutedEventArgs
4 using System.Windows.Threading; // Dispatcher
6 namespace SDKSample
8 // THIS WINDOW RUNS ON A SECONDARY UI THREAD
9 public partial class SecondaryUiThreadWindow : Window
11 public SecondaryUiThreadWindow()
13 InitializeComponent();
15 this.Title = string.Format("Running on Secondary UI Thread {0}", Thread.CurrentThread.ManagedThreadId);
18 void raiseExceptionOnSecondaryUIThreadButton_Click(object sender, RoutedEventArgs e)
20 // Raise an exception on the secondary UI thread
21 string msg = string.Format("Exception raised on secondary UI thread {0}.", Dispatcher.CurrentDispatcher.Thread.ManagedThreadId);
22 throw new Exception(msg);
25 void SecondaryUiThreadWindow_Closed(object sender, EventArgs e)
27 // End this thread of execution
28 Dispatcher.CurrentDispatcher.InvokeShutdown();