Microsoft.VisualStudio.Project.FileChangeManager.StopObservingItem C# (CSharp) Method

StopObservingItem() public method

Stop observing when the file is updated on disk.
public StopObservingItem ( string fileName ) : void
fileName string File to stop observing.
return void
        public virtual void StopObservingItem(string fileName)
        {
            #region Input validation
            if(String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException(SR.GetString(SR.InvalidParameter, CultureInfo.CurrentUICulture), "fileName");
            }
            #endregion

            string fullFileName = Utilities.CanonicalizeFileName(fileName);

            if(this.observedItems.ContainsKey(fullFileName))
            {
                // Get the cookie that was used for this.observedItems to this file.
                ObservedItemInfo itemInfo = this.observedItems[fullFileName];

                // Remove the file from our observed list. It's important that this is done before the call to
                // UnadviseFileChange, because for some reason, the call to UnadviseFileChange can trigger a
                // FilesChanged event, and we want to be able to filter that event away.
                this.observedItems.Remove(fullFileName);

                // Stop observing the file
                ErrorHandler.ThrowOnFailure(this.fileChangeService.UnadviseFileChange(itemInfo.FileChangeCookie));
            }
        }

Usage Example

Esempio n. 1
0
        protected void StopObservingItem(string url)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (filechangemanager != null)
            {
                filechangemanager.StopObservingItem(url);
            }
        }