/// <summary>
 /// Invoked by <see cref="ArchiveListSnapshot{TKey,TValue}.Dispose"/> method.
 /// </summary>
 /// <param name="archiveLists"></param>
 private void ReleaseClientResources(ArchiveListSnapshot <TKey, TValue> archiveLists)
 {
     lock (m_syncRoot)
     {
         m_allSnapshots.Remove(archiveLists);
     }
 }
 /// <summary>
 /// Invoked by <see cref="ArchiveListSnapshot{TKey,TValue}.UpdateSnapshot"/>.
 /// </summary>
 /// <param name="transaction"></param>
 private void UpdateSnapshot(ArchiveListSnapshot <TKey, TValue> transaction)
 {
     lock (m_syncRoot)
     {
         transaction.Tables = new ArchiveTableSummary <TKey, TValue> [m_fileSummaries.Count];
         m_fileSummaries.Values.CopyTo(transaction.Tables, 0);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an object that can be used to get updated snapshots from this <see cref="ArchiveList{TKey,TValue}"/>.
        /// Client must call <see cref="IDisposable.Dispose"/> method when finished with these resources as they will not
        /// automatically be reclaimed by the garbage collector. Class will not be initiallized until calling <see cref="ArchiveListSnapshot{TKey,TValue}.UpdateSnapshot"/>.
        /// </summary>
        /// <returns></returns>
        public ArchiveListSnapshot <TKey, TValue> CreateNewClientResources()
        {
            ArchiveListSnapshot <TKey, TValue> resources;

            lock (m_syncRoot)
            {
                if (m_disposed)
                {
                    throw new Exception("Object is disposing");
                }

                resources = new ArchiveListSnapshot <TKey, TValue>(ReleaseClientResources, UpdateSnapshot);
                m_allSnapshots.Add(resources);
            }

            return(resources);
        }