Browse Source

Add GCNotifier class.

pull/2331/head
Dan Walmsley 7 years ago
parent
commit
d42b22d5e8
  1. 29
      src/Avalonia.Base/Utilities/GCNotifier.cs

29
src/Avalonia.Base/Utilities/GCNotifier.cs

@ -0,0 +1,29 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Avalonia.Utilities
{
public class GCNotifier
{
public static event EventHandler GarbageCollected;
static GCNotifier()
{
new GCNotifier();
}
~GCNotifier()
{
if (Environment.HasShutdownStarted || AppDomain.CurrentDomain.IsFinalizingForUnload())
{
return;
}
new GCNotifier();
GarbageCollected?.Invoke(null, EventArgs.Empty);
}
}
}
Loading…
Cancel
Save