private IList <T> SortData <T>(IEnumerable <T> source, WorkTask workTask = null) where T : IModelWithPersonalId { if (source == null) { return(null); } bool removeTaskAfterCompleted = false; if (workTask == null) { workTask = new("Обработка"); this.workTasksProgressViewModel.WorkTasks.Add(workTask); workTask.StartProcessing(); removeTaskAfterCompleted = true; } workTask.Status = "Сортировка данных"; workTask.IsIndeterminate = true; List <T> result = source.Where(i => i != null).OrderBy(i => i.Лицевой).ToList(); workTask.IsCompleted = true; if (removeTaskAfterCompleted) { this.workTasksProgressViewModel.WorkTasks.Remove(workTask); } return(result); }