1
1
using System ;
2
+ using System . Threading ;
2
3
using System . Windows ;
3
4
using System . Windows . Controls ;
4
- using System . Windows . Data ;
5
- using System . Windows . Documents ;
6
- using System . Windows . Input ;
7
- using System . Windows . Media ;
8
- using System . Threading ;
9
5
using System . Windows . Threading ;
10
6
11
7
namespace SDKSamples
12
8
{
13
9
public partial class Window1 : Window
14
- {
10
+ {
15
11
// Delegate used to place a work item onto the Dispatcher.
16
12
private delegate void UpdateUIDelegate ( Button button ) ;
17
13
@@ -20,7 +16,7 @@ public Window1()
20
16
InitializeComponent ( ) ;
21
17
22
18
// Get the id of the UI thread for display purposes.
23
- _uiThreadID = this . Dispatcher . Thread . ManagedThreadId ;
19
+ _uiThreadID = Dispatcher . Thread . ManagedThreadId ;
24
20
lblUIThreadID . Content = _uiThreadID ;
25
21
}
26
22
@@ -34,7 +30,7 @@ private void TryToUpdateButtonCheckAccess(object uiObject)
34
30
if ( theButton != null )
35
31
{
36
32
// Checking if this thread has access to the object
37
- if ( theButton . CheckAccess ( ) )
33
+ if ( theButton . CheckAccess ( ) )
38
34
{
39
35
// This thread has access so it can update the UI thread
40
36
UpdateButtonUI ( theButton ) ;
@@ -73,7 +69,7 @@ private void TryToUpdateButtonVerifyAccess(object uiObject)
73
69
catch ( InvalidOperationException e )
74
70
{
75
71
// Exception error meessage.
76
- MessageBox . Show ( "Exception ToString: \n \n " + e . ToString ( ) ,
72
+ MessageBox . Show ( "Exception ToString: \n \n " + e . ToString ( ) ,
77
73
"Execption Caught! Thrown During AccessVerify()." ) ;
78
74
79
75
MessageBox . Show ( "Pushing job onto UI Thread Dispatcher" ) ;
@@ -88,7 +84,7 @@ private void TryToUpdateButtonVerifyAccess(object uiObject)
88
84
private void threadStartingCheckAccess ( )
89
85
{
90
86
// Try to update a Button created on the UI thread.
91
- TryToUpdateButtonCheckAccess ( ButtonOnUIThread ) ;
87
+ TryToUpdateButtonCheckAccess ( ButtonOnUIThread ) ;
92
88
}
93
89
94
90
private void threadStartingVerifyAccess ( )
@@ -102,7 +98,7 @@ private void CreateThread(object sender, RoutedEventArgs e)
102
98
ThreadStart threadStartingPoint ;
103
99
104
100
// Determine which ThreadStart to use.
105
- if ( rbCheckAccess . IsChecked )
101
+ if ( rbCheckAccess . IsChecked . Value )
106
102
{
107
103
threadStartingPoint = new ThreadStart ( threadStartingCheckAccess ) ;
108
104
}
@@ -130,4 +126,4 @@ private void UpdateButtonUI(Button theButton)
130
126
private int _uiThreadID ;
131
127
private int _backgroundThreadID ;
132
128
}
133
- }
129
+ }
0 commit comments