Skip to content

Commit

Permalink
MemoryCache - Remove UnhandledException handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenMolloy committed Aug 2, 2024
1 parent cd87c0b commit 49356bc
Showing 1 changed file with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public class MemoryCache : ObjectCache, IEnumerable, IDisposable
private bool _useMemoryCacheManager = true;
private bool _throwOnDisposed;
private EventHandler _onAppDomainUnload;
private UnhandledExceptionEventHandler _onUnhandledException;
#if NETCOREAPP
[UnsupportedOSPlatformGuard("browser")]
private static bool _countersSupported => !OperatingSystem.IsBrowser();
Expand Down Expand Up @@ -219,9 +218,6 @@ private void InitDisposableMembers(NameValueCollection config)
EventHandler onAppDomainUnload = new EventHandler(OnAppDomainUnload);
appDomain.DomainUnload += onAppDomainUnload;
_onAppDomainUnload = onAppDomainUnload;
UnhandledExceptionEventHandler onUnhandledException = new UnhandledExceptionEventHandler(OnUnhandledException);
appDomain.UnhandledException += onUnhandledException;
_onUnhandledException = onUnhandledException;
dispose = false;
}
finally
Expand All @@ -238,16 +234,6 @@ private void OnAppDomainUnload(object unusedObject, EventArgs unusedEventArgs)
Dispose();
}

private void OnUnhandledException(object sender, UnhandledExceptionEventArgs eventArgs)
{
// if the CLR is terminating, dispose the cache.
// This will dispose the perf counters
if (eventArgs.IsTerminating)
{
Dispose();
}
}

private static void ValidatePolicy(CacheItemPolicy policy)
{
if (policy.AbsoluteExpiration != ObjectCache.InfiniteAbsoluteExpiration
Expand Down Expand Up @@ -500,10 +486,6 @@ private void DisposeSafeCritical()
{
appDomain.DomainUnload -= _onAppDomainUnload;
}
if (_onUnhandledException != null)
{
appDomain.UnhandledException -= _onUnhandledException;
}
}

private object GetInternal(string key, string regionName)
Expand Down

0 comments on commit 49356bc

Please sign in to comment.