Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

File change event Hit more than once.

$
0
0

Hi,

I am registering the file we add in project for tracking changes to file. For this I have used IVsFileChangeEvents. Problem is when i add the file to the project then also it is hitting IVsFileChangeEvents.FilesChanged method and it is hitting the the method more than once. 

I do not want this method to be hit when we add a file in the project. I want this method to be hit only when we change the content of the file. And also it should not hit more than once.

Code is attached.

//below code is registering the file to file change event

 string scFileName = System.IO.Path.GetDirectoryName(_ProjectNode.Url) + "\\" + _currentFileName + FileExtension;
                                //subscribe to file watcher.
                                SourceControlOpenUpdate _openUpdate = new SourceControlOpenUpdate(_ProjectNode, HostConnector, _ProjectNode.Url);
                                FileChangeTracker fileChangeTracker = new FileChangeTracker(_ProjectNode.Site, scFileName);
                                fileChangeTracker.EnsureSubscription();
                                fileChangeTracker.UpdatedOnDisk += _openUpdate.SourceControlFileChanged;
                                fileAddVariable = true;




//below method is hitting again and again
int IVsFileChangeEvents.FilesChanged(uint changeCount, string[] files, uint[] changes)
        {
            _fileChangeService.UnadviseFileChange(newCookie);
            var handler = UpdatedOnDisk;

            if (handler != null)
            {
                handler(this, EventArgs.Empty);
            }
            _fileChangeService.AdviseFileChange(_filePath, (uint)_VSFILECHANGEFLAGS.VSFILECHG_Time, this, out newCookie);
            return 0;
        }

Please anyone can help.

Thanks in advance


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>