示例#1
0
        private (LineCount current, LineCount previous) AddOrUpdateLineCount(string filePath, int count)
        {
            var       current = new LineCount(count);
            LineCount previous;

            lock (PathLineCounts)
            {
                if (PathLineCounts.TryGetValue(filePath, out previous))
                {
                    PathLineCounts.Remove(filePath);
                }

                PathLineCounts.Add(filePath, current);
            }

            return(current, previous);
        }
示例#2
0
        public void OnFileRemoved(TrackedFileEventArgs file)
        {
            var filePath = file.Path;

            // Cancel an outstanding line count task for this file, if one exists
            lock (OutstandingLineCounts)
            {
                if (OutstandingLineCounts.TryGetValue(filePath, out var task))
                {
                    task.Cancel();
                }
            }

            lock (PathLineCounts)
            {
                // NOTE: if the key doesn't exist, the method will return null,
                // not throw an exception, per method documentation
                PathLineCounts.Remove(filePath);
            }
        }