//if collections are equal, cleaning will not occur private static async Task <bool> СollectionEqualityTest <T>( this ControlCollection controlCollection, IList <T> newEntity, CancellationToken token) where T : class, IEntity { return(await Task <bool> .Factory.StartNew(() => { var countSameValues = controlCollection.Count == newEntity.Count() ? newEntity.Count(nE => !controlCollection.IsContainControl <T>(nE.Id)) : -1; Console.WriteLine($"countSameValues - {countSameValues}"); return countSameValues == 0; }, token)); }