aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs')
-rw-r--r--MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs21
1 files changed, 16 insertions, 5 deletions
diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
index 09e0e91f5..ce6224295 100644
--- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
+++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs
@@ -310,12 +310,23 @@ namespace MediaBrowser.Server.Implementations.IO
/// <param name="watcher">The watcher.</param>
private void DisposeWatcher(FileSystemWatcher watcher)
{
- Logger.Info("Stopping directory watching for path {0}", watcher.Path);
-
- watcher.EnableRaisingEvents = false;
- watcher.Dispose();
+ try
+ {
+ using (watcher)
+ {
+ Logger.Info("Stopping directory watching for path {0}", watcher.Path);
- RemoveWatcherFromList(watcher);
+ watcher.EnableRaisingEvents = false;
+ }
+ }
+ catch
+ {
+
+ }
+ finally
+ {
+ RemoveWatcherFromList(watcher);
+ }
}
/// <summary>