Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Src/Common/FwUtils/EventConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
11 changes: 7 additions & 4 deletions Src/LexText/ParserUI/ParserListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <summary>
Expand Down Expand Up @@ -202,16 +203,17 @@ public void DisconnectFromParser()
m_parserConnection = null;
}

public bool OnIdle(object argument)
/// <summary>
/// Method to handle published Idle messages.
/// </summary>
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;
Expand Down Expand Up @@ -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.
Expand Down
31 changes: 11 additions & 20 deletions Src/XCore/xCoreInterfaces/Mediator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ public bool SendMessage(string messageName, object parameter)

/// ------------------------------------------------------------------------------------
/// <summary>
/// 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.
/// </summary>
/// <returns><c>true</c> if the message was handled, otherwise <c>false</c></returns>
/// ------------------------------------------------------------------------------------
Expand All @@ -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
Comment on lines +824 to 828
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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)},
Expand Down
9 changes: 3 additions & 6 deletions Src/XCore/xWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/// <summary>
Expand Down Expand Up @@ -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
Expand Down
Loading