using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace FWindSoft.Wpf
{
public static class WindowExtension
{
private static PropertyInfo m_IsDisposedPropertyInfo;
///
/// 判断窗体是否释放
///
///
///
public static bool IsDisposed(this System.Windows.Window window)
{
if (window == null)
return true;
if (m_IsDisposedPropertyInfo == null)
{
var type = typeof(System.Windows.Window);
m_IsDisposedPropertyInfo=type.GetProperty("IsDisposed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
if (m_IsDisposedPropertyInfo != null)
{
return (bool)m_IsDisposedPropertyInfo.GetValue(window);
}
return true;
}
}
}