UserCacheEntry AddUserToCache(User user) { UserCacheEntry cacheentry = new UserCacheEntry(user); usersbyname[new UserKey(user.Service, user.Name)] = cacheentry; usersbyid[user.ID] = cacheentry; users.Add(new UserCacheEntry(user)); return(cacheentry); }
void ITimerService.Process(double time) { lock (userlock) { for (int i = users.Count - 1; i >= 0; --i) { UserCacheEntry user = users[i]; user.LifeTime -= time; if (user.LifeTime <= 0.0) { usersbyname.Remove(new UserKey(user.User.Service, user.User.Name)); usersbyid.Remove(user.User.ID); users.RemoveAt(i); } } } }