Remove the finalizer of ControlSizeTrigger (#31)

This commit is contained in:
Tian L 2021-05-24 15:10:23 +08:00 committed by GitHub
commit dce7d2a568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
@ -49,21 +49,6 @@ namespace CalculatorApp.Views.StateTriggers
public static readonly DependencyProperty MinWidthProperty =
DependencyProperty.Register(nameof(MinWidth), typeof(double), typeof(ControlSizeTrigger), new PropertyMetadata(-1));
~ControlSizeTrigger()
{
// CSHARP_MIGRATION: TODO:
// finalization will happen on a finalizer's thread.
// to prevent crashing the entire app, switch to UI thread to do unregistering work
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
UnregisterSizeChanged(Source);
})
.AsTask()
.ConfigureAwait(false)
.GetAwaiter()
.GetResult();
}
private void OnSourcePropertyChanged(FrameworkElement oldValue, FrameworkElement newValue)
{
UnregisterSizeChanged(oldValue);