diff options
author | Alexis Christoforides <alexis@thenull.net> | 2019-07-08 20:45:49 +0300 |
---|---|---|
committer | Alexis Christoforides <alexis@thenull.net> | 2019-07-15 23:25:32 +0300 |
commit | 532605f53397f966b9b3dfff4e3f6452956d22fa (patch) | |
tree | abb9d5537c875f5b2e78ee67376a0cc232010536 /mcs/class/System/System.IO/FileSystemWatcher.cs | |
parent | 4b6f49bb064dd3a717daddc7ed9dec3659dfcc08 (diff) |
[System] Keep events from firing from a disposed 'DefaultWatcher' FileSystemWatcher
Fixes https://github.com/mono/mono/issues/8747
Also try to stop other implementations from dispatching events past Dispose(), without guaranteeing it
Diffstat (limited to 'mcs/class/System/System.IO/FileSystemWatcher.cs')
-rw-r--r-- | mcs/class/System/System.IO/FileSystemWatcher.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mcs/class/System/System.IO/FileSystemWatcher.cs b/mcs/class/System/System.IO/FileSystemWatcher.cs index adfd9cfc336..b7ad29d0c08 100644 --- a/mcs/class/System/System.IO/FileSystemWatcher.cs +++ b/mcs/class/System/System.IO/FileSystemWatcher.cs @@ -420,6 +420,8 @@ namespace System.IO { } private void RaiseEvent (Delegate ev, EventArgs arg, EventType evtype) { + if (disposed) + return; if (ev == null) return; @@ -497,11 +499,15 @@ namespace System.IO { internal void DispatchErrorEvents (ErrorEventArgs args) { + if (disposed) + return; OnError (args); } internal void DispatchEvents (FileAction act, string filename, ref RenamedEventArgs renamed) { + if (disposed) + return; if (waiting) { lastData = new WaitForChangedResult (); } |