コード例 #1
0
        /// <summary>
        /// 更新缓存信息
        /// </summary>
        /// <param name="changeUsers"></param>
        /// <returns></returns>
        public string SetUserList(List <User_Detail> changeUsers)
        {
            if (IsBusies)
            {
                return("正在更新用户信息");
            }

            IsBusies = true;
            try
            {
                lock (UserList)
                {
                    foreach (var item in changeUsers)
                    {
                        var itemIndex = UserList.FindIndex(m => m.UserId == item.UserId);
                        if (itemIndex < 0)
                        {
                            UserList.Add(item);
                        }
                        else
                        {
                            UserList[itemIndex] = item;
                        }
                    }
                    //最后更新时间
                    LastUpdateTime = DateTime.Now;
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                IsBusies = false;
            }

            return("");
        }