public void Dispose() { if (_cookie != 0) { uint ck = _cookie; _cookie = 0; IVsFileChangeEx fx = GetService <IVsFileChangeEx>(typeof(SVsFileChangeEx)); if (fx != null) { if (!_monitorDir) { fx.UnadviseFileChange(ck); } else { fx.UnadviseDirChange(ck); } } } if (_odt != null) { _odt.IgnoreChanges(_toMonitor, false); _odt = null; } }
internal void OpenTracker() { Debug.WriteLine("==== Open Tracker"); trackers.Clear(); var solutionFileName = GetSolutionFileName(); if (!string.IsNullOrEmpty(solutionFileName)) { monitorFolder = Path.GetDirectoryName(solutionFileName); GetLoadedControllableProjects().ForEach(h => AddProject(h as IVsHierarchy)); if (monitorFolder != lastMinotorFolder) { RemoveFolderMonitor(); IVsFileChangeEx fileChangeService = _sccProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; if (VSConstants.VSCOOKIE_NIL != _vsIVsFileChangeEventsCookie) { fileChangeService.UnadviseDirChange(_vsIVsFileChangeEventsCookie); } fileChangeService.AdviseDirChange(monitorFolder, 1, this, out _vsIVsFileChangeEventsCookie); lastMinotorFolder = monitorFolder; Debug.WriteLine("==== Monitoring: " + monitorFolder + " " + _vsIVsFileChangeEventsCookie); } } }
private void Unwatch(uint cookie) { if (_changeService == null || cookie == 0) { return; } ErrorHandler.ThrowOnFailure(_changeService.UnadviseDirChange(cookie)); }
private void RemoveFolderMonitor() { if (VSConstants.VSCOOKIE_NIL != _vsIVsFileChangeEventsCookie) { IVsFileChangeEx fileChangeService = _sccProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; fileChangeService.UnadviseDirChange(_vsIVsFileChangeEventsCookie); Debug.WriteLine("==== Stop Monitoring: " + _vsIVsFileChangeEventsCookie.ToString()); _vsIVsFileChangeEventsCookie = VSConstants.VSCOOKIE_NIL; lastMinotorFolder = ""; } }