/// <summary> /// Removes an object from the Validation Manager. /// </summary> /// <param name="obj">The object to be removed.</param> protected void RemoveObject(ISupportValidation obj) { lock (this.objects) { lock (this.validationResults) { lock (this.validationQueue) { if (this.objects.Contains(obj)) { this.objects.Remove(obj); ISupportValidationNotification notifyValidityAffected = obj as ISupportValidationNotification; if (notifyValidityAffected != null) { notifyValidityAffected.ValidityAffected -= this.OnValidityAffected; } HashCollection <ValidationResult> validationResults = this.validationResults[obj]; foreach (ValidationResult validationResult in new List <ValidationResult> (validationResults)) { validationResults.Remove(validationResult); ValidationResult currentValidationResult = validationResult; SendOrPostCallback raiseRemovedEvent = delegate { this.RaiseValidationResultRemovedEvent(currentValidationResult); }; this.asyncOperation.Post(raiseRemovedEvent, null); } this.validationResults.Remove(obj); if (this.validationQueue.Contains(obj)) { this.validationQueue.Remove(obj); } } } } } }