Merge pull request #4386 from Sergio0694/feature/nct-712-changes
Fix app domain unloading issue on .NET Framework
This commit is contained in:
Коммит
4a09bf0453
|
@ -41,6 +41,16 @@ namespace System
|
|||
/// <param name="target">The target object to pass as argument to <paramref name="callback"/>.</param>
|
||||
public static void Register(Action<object> callback, object target)
|
||||
{
|
||||
#if NETSTANDARD2_0
|
||||
if (RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework"))
|
||||
{
|
||||
// On .NET Framework using a GC callback causes issues with app domain unloading,
|
||||
// so the callback is not registered if that runtime is detected and just ignored.
|
||||
// Users on .NET Framework will have to manually trim the messenger, if they'd like.
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
_ = new Gen2GcCallback(callback, target);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace Microsoft.Toolkit.Mvvm.Messaging
|
|||
/// The <see cref="WeakReferenceMessenger"/> type will automatically perform internal trimming when
|
||||
/// full GC collections are invoked, so calling <see cref="Cleanup"/> manually is not necessary to
|
||||
/// ensure that on average the internal data structures are as trimmed and compact as possible.
|
||||
/// Note: this is not supported when running on .NET Framework, due to app domain unloading issues.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public sealed class WeakReferenceMessenger : IMessenger
|
||||
|
|
Загрузка…
Ссылка в новой задаче