using System;
using System.Threading;
using System.Windows;
using System.Windows.Threading;
using System.ComponentModel;
using System.Diagnostics;
namespace WpfHelper
{
public static class ThreadingHelper
{
///
/// Processes all messages currently in the message queue.
///
///
/// This method can potentially cause code re-entrancy problem, so use it with great care.
///
public static void DoEvents()
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));
}
}
///
/// **Now redundant see use of ActiveSharp**
/// The purpose of this class is to allow property changes (via INotifyPropertyChanged)
/// without having to hard-code the name of the property (which breaks refactoring).
/// See: http://ascendedguard.com/2007/08/easier-managing-of-inotifypropertychang.html
///
///
public class PropertyChanger
{
//public static void PropChanged(object callerobject, PropertyChangedEventHandler PropertyChanged)
//{
// if (PropertyChanged != null)
// {
// string propertyname = new StackTrace().GetFrame(1).GetMethod().Name;
// string accessor = propertyname.Substring(0, 4);
// propertyname = propertyname.Substring(4);
// if (((accessor == "set_") || (accessor == "get_")) && (propertyname.Length > 0))
// {
// if (IsProperty(callerobject, propertyname))
// {
// PropertyChanged(callerobject, new PropertyChangedEventArgs(propertyname));
// }
// else
// {
// throw new Exception(propertyname + " is not a property.");
// }
// }
// else
// {
// throw new Exception("Calling method is not a get or set accessor: " + propertyname);
// }
// }
//}
//private static bool IsProperty(object callerobject, string propertyname)
//{
// return callerobject.GetType().GetProperty(propertyname) != null;
//}
}
}