A call to AddRange is performed with source repeating. If for any reason he encounters an exception, any that was previously acquired will be deleted. Consider this example:
var filenames = new[] { "file1.xml", "file2.xml", "doesnotexist.xml" }; var disposables = filenames.Select(fn => File.OpenRead(fn)); var fileStreams = disposables.Acquire();
No exception will be thrown if you assign disposables due to lazy pricing. However, when the AddRange call inside Aquire reaches the third element (where it tries to open "doesnotexist.xml" ), a FileNotFoundException will be FileNotFoundException . When this happens, Acquire will safely delete previous threads. A simple ToList / ToArray will leave the first two files open.
In essence, Acquire exists to ensure that either all files in filenames safe to open, or none of them.
source share