0

我正在将缓存依赖对象添加到此类 AggregateCacheDependency 的数组中。当我完成数组时,我会处理它。我的问题是我必须只处理包含对象的数组还是必须先处理它们自己的对象?

4

1 回答 1

1

您不需要在 AggregateCacheDependency 中显式处理对象,因为它会处理其对象本身的处理。这是 AggregateCacheDependency 的方法,它在其数组中处理每个对象:

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();
                }
            }
        }
于 2013-09-30T08:23:15.427 回答