4
我有一个简单的顺序表达,使资源的使用,我想清理,当我说完:资源管理
type MyObject() =
member this.Items =
seq {
use resource = ResourcePool.Get()
let c = resource.ValueCount
if c > 0 then
for i in 0 .. c - 1 do
yield resource.GetValue i
}
如果然后,我使用序列迭代,比如说,在项目中途进行迭代,资源何时处置?
例如:
将resource
被布置Seq.find后
// ...
let foo = MyObject
let item = foo.Items |> Seq.find (fun i -> i.Name = "name")
// ...
完成?还是需要重新考虑我的资源管理策略?
我想这就是我害怕...... IEnumerator何时处置?我的资源是否会长时间留在记忆中? – JDB
简短的回答是否定的。我添加了更多的细节。 – Daniel