Skip to content

Commit

Permalink
More work related to commit SHA-1: 43b1fe0 : fix crashes at applicati…
Browse files Browse the repository at this point in the history
…on shutdown
  • Loading branch information
GerHobbelt committed Nov 3, 2019
1 parent 06bddf6 commit d05bbe2
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions Utilities/GUI/WPFDoEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,31 @@ public static bool CurrentThreadIsUIThread()

public static void InvokeInUIThread(Action action, Dispatcher override_dispatcher = null)
{
if (override_dispatcher != null)
try
{
if (!override_dispatcher.CheckAccess())
if (override_dispatcher != null)
{
override_dispatcher.Invoke(action, DispatcherPriority.Normal);
if (!override_dispatcher.CheckAccess())
{
override_dispatcher.Invoke(action, DispatcherPriority.Normal);
}
else
{
action.Invoke();
}
}
else if (!CurrentThreadIsUIThread())
{
Application.Current.Dispatcher.Invoke(action, DispatcherPriority.Normal);
}
else
{
action.Invoke();
}
}
else if (!CurrentThreadIsUIThread())
{
Application.Current.Dispatcher.Invoke(action, DispatcherPriority.Normal);
}
else
catch (Exception ex)
{
action.Invoke();
Logging.Error(ex, "InvokeInUIThread");
}
}

Expand Down

0 comments on commit d05bbe2

Please sign in to comment.