Esempio n. 1
0
            public IFileWatchingToken EnqueueWatchingFile(string filePath)
            {
                // If we already have this file under our path, we don't have to do additional watching
                if (_directoryFilePathOpt != null && filePath.StartsWith(_directoryFilePathOpt))
                {
                    return(_noOpFileWatchingToken);
                }

                var token = new FileWatchingToken();

                lock (_gate)
                {
                    _activeFileWatchingTokens.Add(token);
                }

                _fileChangeWatcher.EnqueueWork(service =>
                {
                    uint cookie;
                    ErrorHandler.ThrowOnFailure(service.AdviseFileChange(filePath, (uint)(_VSFILECHANGEFLAGS.VSFILECHG_Size | _VSFILECHANGEFLAGS.VSFILECHG_Time), this, out cookie));

                    token.Cookie = cookie;
                });

                return(token);
            }
Esempio n. 2
0
            public IFileWatchingToken EnqueueWatchingFile(string filePath)
            {
                // If we already have this file under our path, we don't have to do additional watching
                if (_directoryFilePath != null && filePath.StartsWith(_directoryFilePath))
                {
                    return(_noOpFileWatchingToken);
                }

                var token = new FileWatchingToken();

                lock (_gate)
                {
                    _activeFileWatchingTokens.Add(token);
                }

                _fileChangeWatcher.EnqueueWork(async service =>
                {
                    token.Cookie = await service.AdviseFileChangeAsync(filePath, _VSFILECHANGEFLAGS.VSFILECHG_Size | _VSFILECHANGEFLAGS.VSFILECHG_Time, this).ConfigureAwait(false);
                });

                return(token);
            }
Esempio n. 3
0
 private Task UnsubscribeFileChangeEventsAsync(IVsAsyncFileChangeEx service, FileWatchingToken typedToken)
 {
     return(service.UnadviseFileChangeAsync(typedToken.Cookie !.Value));
 }
Esempio n. 4
0
 private void UnsubscribeFileChangeEvents(IVsFileChangeEx service, FileWatchingToken typedToken)
 {
     ErrorHandler.ThrowOnFailure(service.UnadviseFileChange(typedToken.Cookie.Value));
 }