我将缓存依赖项的对象添加到此类AggregateCacheDependency的数组中。当我完成阵列时,我处理它。我的问题是我必须只处理包含对象的数组,还是我必须自己处理它们之前的对象?
答案 0 :(得分:1)
您需要在AggregateCacheDependency中显式处置对象,因为它会对其对象本身进行处理。以下是AggregateCacheDependency的metohod,它将每个对象放在其数组中:
protected override void DependencyDispose()
{
CacheDependency[] array = null;
bool flag = false;
try
{
Monitor.Enter(this, ref flag);
this._disposed = true;
if (this._dependencies != null)
{
array = (CacheDependency[])this._dependencies.ToArray(typeof(CacheDependency));
this._dependencies = null;
}
}
finally
{
if (flag)
{
Monitor.Exit(this);
}
}
if (array != null)
{
CacheDependency[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
CacheDependency cacheDependency = array2[i];
cacheDependency.DisposeInternal();
}
}
}