mirror of
https://github.com/PowerShell/PSReadLine
synced 2026-06-08 12:12:13 +00:00
Make sure to generate the 'OnIdle' event when there are other subscribers (#899)
This commit is contained in:
+6
-12
@@ -206,28 +206,22 @@ namespace Microsoft.PowerShell
|
||||
bool runPipelineForEventProcessing = false;
|
||||
foreach (var sub in eventSubscribers)
|
||||
{
|
||||
if (sub.SourceIdentifier.Equals("PowerShell.OnIdle", StringComparison.OrdinalIgnoreCase))
|
||||
runPipelineForEventProcessing = true;
|
||||
if (sub.SourceIdentifier.Equals(PSEngineEvent.OnIdle, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// There is an OnIdle event. We're idle because we timed out. Normally
|
||||
// PowerShell generates this event, but PowerShell assumes the engine is not
|
||||
// idle because it called PSConsoleHostReadLine which isn't returning.
|
||||
// So we generate the event instead.
|
||||
_singleton._engineIntrinsics.Events.GenerateEvent("PowerShell.OnIdle", null, null, null);
|
||||
runPipelineForEventProcessing = true;
|
||||
break;
|
||||
}
|
||||
_singleton._engineIntrinsics.Events.GenerateEvent(PSEngineEvent.OnIdle, null, null, null);
|
||||
|
||||
// If there are any event subscribers that have an action (which might
|
||||
// write to the console) and have a source object (i.e. aren't engine
|
||||
// events), run a tiny useless bit of PowerShell so that the events
|
||||
// can be processed.
|
||||
if (sub.Action != null && sub.SourceObject != null)
|
||||
{
|
||||
runPipelineForEventProcessing = true;
|
||||
// Break out so we don't genreate more than one 'OnIdle' event for a timeout.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are any event subscribers, run a tiny useless PowerShell pipeline
|
||||
// so that the events can be processed.
|
||||
if (runPipelineForEventProcessing)
|
||||
{
|
||||
if (ps == null)
|
||||
|
||||
Reference in New Issue
Block a user