summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events/ManagedEvent.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-08 21:18:15 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-08 21:18:15 -0500
commitbdb7b04b3edecdf7dfa665d8b5a50a1bbff62699 (patch)
tree7249d86910ce37a93a82db8322fade5465445dc4 /src/SMAPI/Framework/Events/ManagedEvent.cs
parent04c6733adae9ce568aefb5d9dee6101097e994c5 (diff)
parentdf25368300e1254bc6eb2a1c7aa371bfeb289dff (diff)
downloadSMAPI-bdb7b04b3edecdf7dfa665d8b5a50a1bbff62699.tar.gz
SMAPI-bdb7b04b3edecdf7dfa665d8b5a50a1bbff62699.tar.bz2
SMAPI-bdb7b04b3edecdf7dfa665d8b5a50a1bbff62699.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Events/ManagedEvent.cs')
-rw-r--r--src/SMAPI/Framework/Events/ManagedEvent.cs44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs
index f2dfb2ab..2204966c 100644
--- a/src/SMAPI/Framework/Events/ManagedEvent.cs
+++ b/src/SMAPI/Framework/Events/ManagedEvent.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using StardewModdingAPI.Events;
-using StardewModdingAPI.Framework.PerformanceMonitoring;
namespace StardewModdingAPI.Framework.Events
{
@@ -17,9 +16,6 @@ namespace StardewModdingAPI.Framework.Events
/// <summary>The mod registry with which to identify mods.</summary>
protected readonly ModRegistry ModRegistry;
- /// <summary>Tracks performance metrics.</summary>
- private readonly PerformanceMonitor PerformanceMonitor;
-
/// <summary>The underlying event handlers.</summary>
private readonly List<ManagedEventHandler<TEventArgs>> Handlers = new List<ManagedEventHandler<TEventArgs>>();
@@ -49,13 +45,11 @@ namespace StardewModdingAPI.Framework.Events
/// <summary>Construct an instance.</summary>
/// <param name="eventName">A human-readable name for the event.</param>
/// <param name="modRegistry">The mod registry with which to identify mods.</param>
- /// <param name="performanceMonitor">Tracks performance metrics.</param>
/// <param name="isPerformanceCritical">Whether the event is typically called at least once per second.</param>
- public ManagedEvent(string eventName, ModRegistry modRegistry, PerformanceMonitor performanceMonitor, bool isPerformanceCritical = false)
+ public ManagedEvent(string eventName, ModRegistry modRegistry, bool isPerformanceCritical = false)
{
this.EventName = eventName;
this.ModRegistry = modRegistry;
- this.PerformanceMonitor = performanceMonitor;
this.IsPerformanceCritical = isPerformanceCritical;
}
@@ -126,40 +120,26 @@ namespace StardewModdingAPI.Framework.Events
}
// raise event
- this.PerformanceMonitor.Track(this.EventName, () =>
+ foreach (ManagedEventHandler<TEventArgs> handler in handlers)
{
- foreach (ManagedEventHandler<TEventArgs> handler in handlers)
- {
- if (match != null && !match(handler.SourceMod))
- continue;
+ if (match != null && !match(handler.SourceMod))
+ continue;
- try
- {
- this.PerformanceMonitor.Track(this.EventName, this.GetModNameForPerformanceCounters(handler), () => handler.Handler.Invoke(null, args));
- }
- catch (Exception ex)
- {
- this.LogError(handler, ex);
- }
+ try
+ {
+ handler.Handler.Invoke(null, args);
+ }
+ catch (Exception ex)
+ {
+ this.LogError(handler, ex);
}
- });
+ }
}
/*********
** Private methods
*********/
- /// <summary>Get the mod name for a given event handler to display in performance monitoring reports.</summary>
- /// <param name="handler">The event handler.</param>
- private string GetModNameForPerformanceCounters(ManagedEventHandler<TEventArgs> handler)
- {
- IModMetadata mod = handler.SourceMod;
-
- return mod.HasManifest()
- ? mod.Manifest.UniqueID
- : mod.DisplayName;
- }
-
/// <summary>Log an exception from an event handler.</summary>
/// <param name="handler">The event handler instance.</param>
/// <param name="ex">The exception that was raised.</param>