Is the following object thread safe? I'll make one instance and use it using two or more threads, is this a good way to approach this?
public class ASyncBuffer<T>
{
readonly object _locker = new object();
private T _value;
private bool _dirty;
public T GetValue()
{
lock (_locker)
{
_dirty = false;
return _value;
}
}
public void SetValue(T value)
{
lock (_locker)
{
_dirty = true;
_value = value;
}
}
public bool Dirty
{
get
{
lock (_locker)
{
return _dirty;
}
}
}
}