Skip to content

Commit

Permalink
Fix NullReferenceException
Browse files Browse the repository at this point in the history
Fix NullReferenceException in FileSystemWatcher on Windows if two threads try and dispose the instance at the same time.
  • Loading branch information
martincostello authored Apr 8, 2024
1 parent bc2bd2b commit 8c1227b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void StopRaisingEvents()
// increased, such that the disposal operation won't take effect and close the handle
// until that P/Invoke returns; if during that time the FSW is restarted, the IsHandleInvalid
// check will see a valid handle, unless we also null it out.
_directoryHandle.Dispose();
_directoryHandle?.Dispose();
_directoryHandle = null;
}

Expand Down

0 comments on commit 8c1227b

Please sign in to comment.