We just started working with an odd problem with FileSystemWatcher, where the Dispose () call is called. This is code that worked without any problems for a while, but we just upgraded to .NET3.5 SP1, so I'm trying to find out if anyone has seen this behavior. Here is the code that creates the FileSystemWatcher:
if (this.fileWatcher == null) { this.fileWatcher = new FileSystemWatcher(); } this.fileWatcher.BeginInit(); this.fileWatcher.IncludeSubdirectories = true; this.fileWatcher.Path = project.Directory; this.fileWatcher.EnableRaisingEvents = true; this.fileWatcher.NotifyFilter = NotifyFilters.Attributes; this.fileWatcher.Changed += delegate(object s, FileSystemEventArgs args) { FileWatcherFileChanged(args); }; this.fileWatcher.EndInit();
The way it is used is to update the state image of the TreeNode object (adjusted slightly to remove information about a particular business):
private void FileWatcherFileChanged(FileSystemEventArgs args) { if (this.TreeView != null) { if (this.TreeView.InvokeRequired) { FileWatcherFileChangedCallback d = new FileWatcherFileChangedCallback(FileWatcherFileChanged); this.TreeView.Invoke(d, new object[] { args }); } else { switch (args.ChangeType) { case WatcherChangeTypes.Changed: if (String.CompareOrdinal(this.project.FullName, args.FullPath) == 0) { this.StateImageKey = GetStateImageKey(); } else { projectItemTreeNode.StateImageKey = GetStateImageKey(); } break; } } } }
Is there something we are missing or is this an anomaly from .NET3.5 SP1?
Scott dorman
source share