File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Rubberduck.Parsing/UIContext Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -123,11 +123,23 @@ public static void Shutdown()
123
123
/// <summary>
124
124
/// Used to pump any pending COM messages. This should be used only as a part of
125
125
/// synchronizing or to effect a block until all other threads has finished with
126
- /// their pending COM calls.
126
+ /// their pending COM calls. This should be used by the UI thread **ONLY**.
127
127
/// </summary>
128
- public static void DoEvents ( )
128
+ /// <remarks>
129
+ /// Typical use would be within a event handler for an event belonging to a COM
130
+ /// object which require some synchronization with COM accesses from other threads.
131
+ /// Events raised by COM are on UI thread by definition.
132
+ /// </remarks>
133
+ public static int DoEvents ( )
129
134
{
130
- Invoke ( ( ) => ExecuteDoEvents ( ) ) ;
135
+ CheckInitialization ( ) ;
136
+
137
+ if ( UiContext != SynchronizationContext . Current )
138
+ {
139
+ throw new InvalidOperationException ( "DoEvents cannot be used in other threads" ) ;
140
+ }
141
+
142
+ return ExecuteDoEvents ( ) ;
131
143
}
132
144
133
145
private static int ExecuteDoEvents ( )
You can’t perform that action at this time.
0 commit comments