Skip to content

Commit

Permalink
Merge pull request #3946 from batzen/issues/3944
Browse files Browse the repository at this point in the history
(GH-3944) Use BeginInvoke to prevent deadlocks in multithreaded cases
  • Loading branch information
punker76 committed Oct 23, 2020
2 parents a8ea723 + f318a4f commit 844f85f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MahApps.Metro/Behaviors/WindowsSettingBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private void AssociatedObject_SourceInitialized(object sender, EventArgs e)
window.Closed += this.AssociatedObject_Closed;

// This operation must be thread safe
Application.Current?.Invoke(() => Application.Current.SessionEnding += this.CurrentApplicationSessionEnding);
Application.Current?.BeginInvoke(() => Application.Current.SessionEnding += this.CurrentApplicationSessionEnding);
}

private void AssociatedObject_Closing(object sender, System.ComponentModel.CancelEventArgs e)
Expand Down Expand Up @@ -93,7 +93,7 @@ private void CleanUp(string fromWhere)
window.SourceInitialized -= this.AssociatedObject_SourceInitialized;

// This operation must be thread safe
Application.Current?.Invoke(() => Application.Current.SessionEnding -= this.CurrentApplicationSessionEnding);
Application.Current?.BeginInvoke(() => Application.Current.SessionEnding -= this.CurrentApplicationSessionEnding);
}

#pragma warning disable 618
Expand Down

0 comments on commit 844f85f

Please sign in to comment.