protected void RemoveDeletedFiles() { Parallel.ForEach(FileLineMap, async kvp => { // new to wait on refresh to determine if the file still exists await Task.Run(() => kvp.Key.Refresh(), CancellationToken); if (!kvp.Key.Exists && FileLineMap.TryRemove(kvp.Key, out _)) { OutputFunction.Invoke($"Deleted: {kvp.Key.Name}"); } }); }