예제 #1
0
        private void m_CleanupTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                System.Collections.ArrayList deletionKeys = new System.Collections.ArrayList();
                //lock(m_ImageTileHash.SyncRoot)
                {
                    foreach (string key in m_ImageTileHash.Keys)
                    {
                        ImageTileCacheEntry tile = (ImageTileCacheEntry)m_ImageTileHash[key];

                        if (System.DateTime.Now.Subtract(tile.LastAccessed) > System.TimeSpan.FromSeconds(30))
                        {
                            deletionKeys.Add(key);
                        }
                    }
                }

                foreach (string key in deletionKeys)
                {
                    ImageTileCacheEntry tile = (ImageTileCacheEntry)m_ImageTileHash[key];
                    m_ImageTileHash.Remove(key);
                    if (tile.Texture != null && !tile.Texture.Disposed)
                    {
                        tile.Texture.Dispose();
                    }
                }
            }
            catch
            {}
        }
예제 #2
0
 public void Add(ImageTileCacheEntry newEntry)
 {
     if (!m_ImageTileHash.Contains(newEntry.Resource))
     {
         m_ImageTileHash.Add(newEntry.Resource, newEntry);
     }
 }
예제 #3
0
        public ImageTileCacheEntry this[string key]
        {
            get
            {
                ImageTileCacheEntry tile = m_ImageTileHash[key] as ImageTileCacheEntry;
                if (tile != null && (tile.Texture == null || tile.Texture.Disposed))
                {
                    tile.Load(m_Device3d);
                }

                if (tile != null)
                {
                    tile.LastAccessed = System.DateTime.Now;
                }
                return(tile);
            }
        }