Add workaround for in-use files

The `TestBase` is not always able to delete the scratch folder in
`Dispose()` because sometimes the files are still in use.

This problem appears to be leaked file handles (likely due to incorrect
handling of `IDisposable`). To avoid the problem for now, force a
garbage collection prior to deleting the scratch folder.
This commit is contained in:
Matt Kotsenas
2018-07-10 11:49:38 -07:00
parent 7b338511cc
commit 3114afde0e

View File

@@ -39,6 +39,12 @@ namespace SharpCompress.Test
public void Dispose()
{
// WARNING: This garbage collection is needed to reclaim leaked file handles
// (likely due to improperly handled IDisposables). Without it, The following
// delete fails because files are still is use. This GC should be removed once
// all the files pass without it.
GC.Collect(2, GCCollectionMode.Forced, true, false);
Directory.Delete(SCRATCH_BASE_PATH, true);
}