@@ -206,28 +206,22 @@ internal static PSKeyInfo ReadKey()
206
206
bool runPipelineForEventProcessing = false ;
207
207
foreach ( var sub in eventSubscribers )
208
208
{
209
- if ( sub . SourceIdentifier . Equals ( "PowerShell.OnIdle" , StringComparison . OrdinalIgnoreCase ) )
209
+ runPipelineForEventProcessing = true ;
210
+ if ( sub . SourceIdentifier . Equals ( PSEngineEvent . OnIdle , StringComparison . OrdinalIgnoreCase ) )
210
211
{
211
212
// There is an OnIdle event. We're idle because we timed out. Normally
212
213
// PowerShell generates this event, but PowerShell assumes the engine is not
213
214
// idle because it called PSConsoleHostReadLine which isn't returning.
214
215
// So we generate the event instead.
215
- _singleton . _engineIntrinsics . Events . GenerateEvent ( "PowerShell.OnIdle" , null , null , null ) ;
216
- runPipelineForEventProcessing = true ;
217
- break ;
218
- }
216
+ _singleton . _engineIntrinsics . Events . GenerateEvent ( PSEngineEvent . OnIdle , null , null , null ) ;
219
217
220
- // If there are any event subscribers that have an action (which might
221
- // write to the console) and have a source object (i.e. aren't engine
222
- // events), run a tiny useless bit of PowerShell so that the events
223
- // can be processed.
224
- if ( sub . Action != null && sub . SourceObject != null )
225
- {
226
- runPipelineForEventProcessing = true ;
218
+ // Break out so we don't genreate more than one 'OnIdle' event for a timeout.
227
219
break ;
228
220
}
229
221
}
230
222
223
+ // If there are any event subscribers, run a tiny useless PowerShell pipeline
224
+ // so that the events can be processed.
231
225
if ( runPipelineForEventProcessing )
232
226
{
233
227
if ( ps == null )
0 commit comments