Hi,
according to this, I can achieve threadsafety with large overhead. I wrote the following class and use it. It works fine.
public abstract class BindingBase : DispatcherObject, INotifyPropertyChanged,
INotifyPropertyChanging
{
private string _displayName;
private const string NameDisplayName = "DisplayName";
///
/// The display name for the gui element which bound this instance. It can be used for localization.
///
public string DisplayName
{
get { return _displayName; }
set
{
NotifyPropertyChanging(NameDisplayName);
_displayName = value;
NotifyPropertyChanged(NameDisplayName);
}
}
protected BindingBase() {}
protected BindingBase(string displayName)
{
DisplayName = displayName;
}
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangingEventHandler PropertyChanging;
protected void NotifyPropertyChanged(string name)
{
if (PropertyChanged == null)
return;
if (CheckAccess())
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(name));
else
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) (() = NotifyPropertyChanged(name)));
}
protected void NotifyPropertyChanging(string name)
{
if (PropertyChanging == null)
return;
if (CheckAccess())
PropertyChanging.Invoke(this, new PropertyChangingEventArgs(name));
else
Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) (() = NotifyPropertyChanging(name)));
}
}
So is there a reason, why I've never found something like that? Are there any issues I should be aware off?
Regards