diff --git a/Src/Common/FwUtils/EventConstants.cs b/Src/Common/FwUtils/EventConstants.cs index 0333c9a635..309e8aad27 100644 --- a/Src/Common/FwUtils/EventConstants.cs +++ b/Src/Common/FwUtils/EventConstants.cs @@ -22,6 +22,7 @@ public static class EventConstants public const string GetContentControlParameters = "GetContentControlParameters"; public const string GetToolForList = "GetToolForList"; public const string HandleLocalHotlink = "HandleLocalHotlink"; + public const string Idle = "Idle"; public const string ItemDataModified = "ItemDataModified"; public const string JumpToField = "JumpToField"; public const string JumpToPopupLexEntry = "JumpToPopupLexEntry"; diff --git a/Src/LexText/ParserUI/ParserListener.cs b/Src/LexText/ParserUI/ParserListener.cs index 7e3c2e1f0e..26965ada0a 100644 --- a/Src/LexText/ParserUI/ParserListener.cs +++ b/Src/LexText/ParserUI/ParserListener.cs @@ -88,6 +88,7 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configu Subscriber.Subscribe(EventConstants.StopParser, StopParser); Subscriber.Subscribe(EventConstants.RefreshPopupWindowFonts, RefreshPopupWindowFonts); + Subscriber.Subscribe(EventConstants.Idle, Idle); } /// @@ -202,16 +203,17 @@ public void DisconnectFromParser() m_parserConnection = null; } - public bool OnIdle(object argument) + /// + /// Method to handle published Idle messages. + /// + private void Idle(object argument) { CheckDisposed(); UpdateStatusPanelProgress(); - - return false; // Don't stop other people from getting the idle message } - // Now called by timer AND by OnIdle + // Now called by timer AND by Idle private void UpdateStatusPanelProgress() { var statusMessage = ParserQueueString + " " + ParserActivityString; @@ -377,6 +379,7 @@ protected virtual void Dispose(bool disposing) { Subscriber.Unsubscribe(EventConstants.StopParser, StopParser); Subscriber.Unsubscribe(EventConstants.RefreshPopupWindowFonts, RefreshPopupWindowFonts); + Subscriber.Unsubscribe(EventConstants.Idle, Idle); // other clients may now parse // Dispose managed resources here. diff --git a/Src/XCore/xCoreInterfaces/Mediator.cs b/Src/XCore/xCoreInterfaces/Mediator.cs index 660d59b1a7..eeaef874d3 100644 --- a/Src/XCore/xCoreInterfaces/Mediator.cs +++ b/Src/XCore/xCoreInterfaces/Mediator.cs @@ -806,7 +806,7 @@ public bool SendMessage(string messageName, object parameter) /// ------------------------------------------------------------------------------------ /// - /// Worker method to invoke commands. It will log the call if it is not an update or idle. + /// Worker method to invoke commands. It will log the call if it is not an update. /// /// true if the message was handled, otherwise false /// ------------------------------------------------------------------------------------ @@ -821,15 +821,12 @@ private bool SendMessageWorker(string messageName, object parameter) Debug.Fail("The convention is to send messages without the 'On' prefix. " + "That is added by the message sending code."); #endif - if (messageName != "Idle") - { - Trace.WriteLineIf(showPendingMsgsSwitch.TraceVerbose, - BuildDebugMsg("SendMessage::Looking for listeners for Msg: " + messageName), - showPendingMsgsSwitch.DisplayName); - } + Trace.WriteLineIf(showPendingMsgsSwitch.TraceVerbose, + BuildDebugMsg("SendMessage::Looking for listeners for Msg: " + messageName), + showPendingMsgsSwitch.DisplayName); string methodName = "On" + messageName; // Logging - if (!messageName.StartsWith("Update") && messageName != "Idle") + if (!messageName.StartsWith("Update")) { // We want to log the method if any colleague handles it. // So we check the list of methods known-to-us first. If we don't find it, @@ -1040,12 +1037,9 @@ public bool BroadcastMessage(string messageName, object parameter) Debug.Fail("The convention is to send messages without the 'On' prefix. " + "That is added by the message sending code."); #endif - if (messageName != "Idle") - { - Trace.WriteLineIf(showPendingMsgsSwitch.TraceVerbose, - BuildDebugMsg("BroadcastMessage::Looking for listeners for Msg: " + messageName), - showPendingMsgsSwitch.DisplayName); - } + Trace.WriteLineIf(showPendingMsgsSwitch.TraceVerbose, + BuildDebugMsg("BroadcastMessage::Looking for listeners for Msg: " + messageName), + showPendingMsgsSwitch.DisplayName); #if false return InvokeOnColleagues("On" + messageName, new Type[] {typeof(object)}, new Object[] { parameter }, false, false); @@ -1094,12 +1088,9 @@ public bool HasReceiver(string messageName) if(messageName.Substring(0,2) == "On") Debug.Fail("The convention is to send messages without the 'On' prefix. That is added by the message sending code."); #endif - if (messageName != "Idle") - { - Trace.WriteLineIf(showPendingMsgsSwitch.TraceVerbose, - BuildDebugMsg("HasReceiver::Checking for listeners for Msg: " + messageName), - showPendingMsgsSwitch.DisplayName); - } + Trace.WriteLineIf(showPendingMsgsSwitch.TraceVerbose, + BuildDebugMsg("HasReceiver::Checking for listeners for Msg: " + messageName), + showPendingMsgsSwitch.DisplayName); return InvokeOnColleagues("On"+messageName, new Type[] {typeof(object)}, diff --git a/Src/XCore/xWindow.cs b/Src/XCore/xWindow.cs index c76c1cde97..48184bae2f 100644 --- a/Src/XCore/xWindow.cs +++ b/Src/XCore/xWindow.cs @@ -1802,10 +1802,8 @@ public void SynchronizedOnIdleTime() UpdateControls(); - // call OnIdle () on any colleagues that implement it. -#pragma warning disable 618 // suppress obsolete warning - m_mediator.SendMessage("Idle", null); -#pragma warning restore 618 + // Notify any subscribers that the application is idle. + Publisher.Publish(new PublisherParameterObject(EventConstants.Idle, null)); } /// @@ -2413,8 +2411,7 @@ private void WidgetUpdateTimer_Tick(object sender, System.EventArgs e) //mi.Invoke(this, new object [] {}); SynchronizedOnIdleTime(); - // This is done in SynchronizedOnIdleTime now, as I can't see why some controls should do idle processing, and others not do it. - // m_mediator.SendMessage("Idle", this); //let listeners and other colleagues do something + // The idle notification is published in SynchronizedOnIdleTime now, as I can't see why some controls should do idle processing, and others not do it. } #endregion Windows Event handlers