/// <summary> /// Marks the event for cancellation. /// </summary> public void Cancel() { if (CanCancel) { ValueSafe.Increment0(ref canceled); return; } throw Error.InvalidOperation(Strings.NotCancelable); }
/// <summary> /// Releases resources used by the <see cref="PropertyObserver"/>. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (disposing && ValueSafe.Increment0(ref disposed)) { lock (table) { foreach (KeyValuePair <INotifyPropertyChanged, Subscriber> pair in table) { Subscriber subscriber = pair.Value; subscriber.Dispose(); PropertyChangedEvent.RemoveListener(pair.Key, subscriber); } table.Clear(); } } }