31 lines
864 B
C#
31 lines
864 B
C#
using System;
|
|
using JD.Threading.Dispatch;
|
|
|
|
namespace JD.TeaBoxAddinSystem.Bootstrap
|
|
{
|
|
/// <summary>
|
|
/// Wraps Application.Idle since excepions that occurs in it are not trapped by the normal unhandled exceptions handler (makes the application close).
|
|
/// </summary>
|
|
|
|
public static class Idle
|
|
{
|
|
static Idle()
|
|
{
|
|
GuiDispatcher.AssertIsUIThread();
|
|
System.Windows.Threading.Dispatcher.CurrentDispatcher.Hooks.DispatcherInactive += Hooks_DispatcherInactive;
|
|
}
|
|
|
|
static void Hooks_DispatcherInactive(object sender, EventArgs e)
|
|
{
|
|
m_event?.Invoke(sender, e);
|
|
}
|
|
|
|
private static event EventHandler m_event;
|
|
|
|
public static event EventHandler Event
|
|
{
|
|
add { m_event += value; }
|
|
remove { m_event -= value; }
|
|
}
|
|
}
|
|
}
|