using System; namespace PingPong.Generic { public class Locked { #region Members /// /// The lock object. /// private object lockObject; /// /// The value. /// private T value; /// /// The is locked. /// private bool isLocked; #endregion #region Properties /// /// Gets or sets the value. /// /// /// The value. /// public T Value { get { return this.value; } set { lock (this.lockObject) { this.isLocked = true; this.value = value; this.isLocked = false; } } } /// /// Gets a value indicating whether this instance is locked. /// /// /// true if this instance is locked; otherwise, false. /// public bool IsLocked { get { return this.isLocked; } } #endregion #region Constructors /// /// Initializes a new instance of the class. /// public Locked() { this.value = default(T); } /// /// Initializes a new instance of the class. /// /// /// Value. /// public Locked(T value) { this.value = value; } #endregion } }