Use EnumerateInvocationList instead of GetInvocationList (#2303)

This commit is contained in:
srkizer 2025-06-24 05:09:48 +09:00 committed by GitHub
parent 13306e24ba
commit 03e728e129
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 402 additions and 294 deletions

View file

@ -350,17 +350,13 @@ internal sealed class Framework : IInternalDisposableService, IFramework
/// <param name="frameworkInstance">The Framework Instance to pass to delegate.</param>
internal void ProfileAndInvoke(IFramework.OnUpdateDelegate? eventDelegate, IFramework frameworkInstance)
{
if (eventDelegate is null) return;
var invokeList = eventDelegate.GetInvocationList();
// Individually invoke OnUpdate handlers and time them.
foreach (var d in invokeList)
foreach (var d in Delegate.EnumerateInvocationList(eventDelegate))
{
var stopwatch = Stopwatch.StartNew();
try
{
d.Method.Invoke(d.Target, new object[] { frameworkInstance });
d(frameworkInstance);
}
catch (Exception ex)
{
@ -370,8 +366,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
stopwatch.Stop();
var key = $"{d.Target}::{d.Method.Name}";
if (this.NonUpdatedSubDelegates.Contains(key))
this.NonUpdatedSubDelegates.Remove(key);
this.NonUpdatedSubDelegates.Remove(key);
AddToStats(key, stopwatch.Elapsed.TotalMilliseconds);
}