Fix ObjectDisposedException in FileSystemWatcher.OSX.cs (#34589)
authorStephen Toub <stoub@microsoft.com>
Tue, 7 Apr 2020 14:49:38 +0000 (10:49 -0400)
committerGitHub <noreply@github.com>
Tue, 7 Apr 2020 14:49:38 +0000 (10:49 -0400)
commit8aa97da569e33767465b889ac3d5507e3b53b815
treef4d51462810e72c88805ea0138547265006658df
parent29ed7befb57220585aa2deb8d35fc62c56cb715e
Fix ObjectDisposedException in FileSystemWatcher.OSX.cs (#34589)

Synchronize access to disposing the SafeHandle, and clean up some code distributed oddly between the ctor and Start, so as to make more fields readonly and only register for cancellation once everything has started, to avoid race conditions that could otherwise result between cancellation and starting happening concurrently.
src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.OSX.cs