Non-null disposed BlockingCollection can throw exception
This commit is contained in:
parent
eff2634b32
commit
ba722487d8
1 changed files with 7 additions and 2 deletions
|
|
@ -79,8 +79,13 @@ namespace FileManager
|
||||||
//Stop raising events
|
//Stop raising events
|
||||||
fileSystemWatcher?.Dispose();
|
fileSystemWatcher?.Dispose();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
//Calling CompleteAdding() will cause background scanner to terminate.
|
//Calling CompleteAdding() will cause background scanner to terminate.
|
||||||
directoryChangesEvents?.CompleteAdding();
|
directoryChangesEvents?.CompleteAdding();
|
||||||
|
}
|
||||||
|
// if directoryChangesEvents is non-null and isDisposed, this exception is thrown. there's no other way to check >:(
|
||||||
|
catch (ObjectDisposedException) { }
|
||||||
|
|
||||||
//Wait for background scanner to terminate before reinitializing.
|
//Wait for background scanner to terminate before reinitializing.
|
||||||
backgroundScanner?.Wait();
|
backgroundScanner?.Wait();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue