public static async Task DeleteAllUnusedDataOnDisk(IFileSystemOperations fileSystemOperations, IMessagingService messagingService, ILoggerService loggerService) { var dateTimeNow = DateTime.Now; var timeElapsed = new TimeSpan((dateTimeNow - Properties.Settings.Default.ConvertingDataFolderCheck).Ticks); if (timeElapsed.TotalHours > ProjectSettings.IntervalHoursToDeleteUnusedPackages) { messagingService.ShowMessage("Очистка пространства на жестком диске..."); loggerService.DebugLog("Очистка пространства на жестком диске..."); KillPreviousRunProcesses(); var result = await Task.Run( () => fileSystemOperations.DeleteAllDataInDirectory(ProjectSettings.ConvertingDirectory, DateTime.Now, ProjectSettings.IntervalHoursToDeleteUnusedPackages)); if (result.HasErrors) { messagingService.ShowAndLogErrors(result.Errors); } Properties.Settings.Default.ConvertingDataFolderCheck = new TimeSpan(dateTimeNow.Ticks); Properties.Settings.Default.Save(); } }