Revert "Non-null disposed BlockingCollection can throw exception"

This reverts commit ba722487d8.
This commit is contained in:
Michael Bucari-Tovo 2022-06-23 11:34:20 -06:00
parent 1a74736115
commit 6411d23744

View file

@ -79,13 +79,8 @@ namespace FileManager
//Stop raising events
fileSystemWatcher?.Dispose();
try
{
//Calling CompleteAdding() will cause background scanner to terminate.
directoryChangesEvents?.CompleteAdding();
}
// if directoryChangesEvents is non-null and isDisposed, this exception is thrown. there's no other way to check >:(
catch (ObjectDisposedException) { }
//Calling CompleteAdding() will cause background scanner to terminate.
directoryChangesEvents?.CompleteAdding();
//Wait for background scanner to terminate before reinitializing.
backgroundScanner?.Wait();