public void RemoveMapItem() { // take the data from list to remove it without having enumeration problems (ToList) try { List <MapItem> dropsToRemove = DroppedList.Where(dl => dl.CreatedDate.AddMinutes(3) < DateTime.Now); Parallel.ForEach(dropsToRemove, drop => { Broadcast(StaticPacketHelper.Out(UserType.Object, drop.TransportId)); DroppedList.Remove(drop.TransportId); }); } catch (Exception e) { Logger.Error(e); } }
private void RemoveMapItem() { // take the data from list to remove it without having enumeration problems (ToList) try { IEnumerable <KeyValuePair <long, MapItem> > dropsToRemove = DroppedList.Where(dl => dl.Value.CreateDate.AddMinutes(3) < DateTime.Now).ToList(); foreach (KeyValuePair <long, MapItem> drop in dropsToRemove) { Broadcast(drop.Value.GenerateOut(drop.Key)); MapItem mapItem; DroppedList.TryRemove(drop.Key, out mapItem); } } catch (Exception e) { Logger.Error(e); } }