Browse Source

Merge pull request #1651 from tznind/dispose-all-watchers

Dispose `FileSystemWatcher` instance before creating another in `FileDialog`
Tig Kindel 3 years ago
parent
commit
9d2d132684
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Terminal.Gui/Windows/FileDialog.cs

+ 4 - 0
Terminal.Gui/Windows/FileDialog.cs

@@ -51,6 +51,10 @@ namespace Terminal.Gui {
 			bool valid = false;
 			try {
 				dirInfo = new DirectoryInfo (value == null ? directory.ToString () : value.ToString ());
+
+				// Dispose of the old watcher
+				watcher?.Dispose ();
+
 				watcher = new FileSystemWatcher (dirInfo.FullName);
 				watcher.NotifyFilter = NotifyFilters.Attributes
 				 | NotifyFilters.CreationTime