Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing deadlock on AppDomain.Unload by removing superfluous finalization logic which uses Dispatcher. #1584

Merged
merged 2 commits into from
Oct 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 3 additions & 21 deletions MahApps.Metro/Controls/FlipView.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MahApps.Metro.Controls
{
Expand Down Expand Up @@ -72,16 +63,7 @@ void FlipView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.Focus();
}
~FlipView()
{
Dispatcher.Invoke(new EmptyDelegate(() =>
{
this.Loaded -= FlipView_Loaded;
}));
}

private delegate void EmptyDelegate();


protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is FlipViewItem;
Expand Down Expand Up @@ -456,14 +438,14 @@ public bool IsBannerEnabled
private static void ExecuteWhenLoaded(FlipView flipview, Action body)
{
if (flipview.IsLoaded)
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(new EmptyDelegate(() => body()));
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(body);
else
{
RoutedEventHandler handler = null;
handler = (o, a) =>
{
flipview.Loaded -= handler;
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(new EmptyDelegate(() => body()));
System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(body);
};

flipview.Loaded += handler;
Expand Down
11 changes: 0 additions & 11 deletions MahApps.Metro/Controls/MetroTabItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@ void MetroTabItem_Unloaded(object sender, RoutedEventArgs e)
closeButtonClickUnloaded = true;
}

~MetroTabItem()
{
if (Application.Current != null)
{
Application.Current.Dispatcher.Invoke(new Action(() =>
{
this.Loaded -= MetroTabItem_Loaded;
}));
}
}

/// <summary>
/// Gets/sets whether the Close Button is visible.
/// </summary>
Expand Down