public Task StartCopyingFiles() { Task task = new Task(async () => { bool hasFailed = false; try { foreach (TempProjectionInfo tempInfo in _inQueue.GetConsumingEnumerable()) { var permInfo = _projectionInfoFactory.CreatePermProjectionInfo(_folderStructure, tempInfo); var destPath = await _fileUtil.CopyFileAsync(tempInfo.FilePath, permInfo.FilePath); _outQueue.TryAdd(permInfo); Logger.Info(CultureInfo.CurrentCulture, permInfo.FileName + " has been moved to " + destPath); } } catch (Exception e) { hasFailed = true; Logger.Fatal("Stops consuming projections due to: " + e.Message); throw; } finally { if (!hasFailed) { _outQueue.CompleteAdding(); } } }, TaskCreationOptions.LongRunning); task.Start(); return task; }