示例#1
0
        private static string Key(Window window, UpdateStatusTaskType ustt)
        {
            var hashCode = window.GetHashCode();
            var key      = hashCode + "-" + ustt;

            return(key);
        }
示例#2
0
        public static void Remove(Window window, UpdateStatusTaskType ustt)
        {
            var key = Key(window, ustt);

            if (dic.ContainsKey(key))
            {
                var found = dic[key];
                found.Stop();
                dic.Remove(key);
            }
        }
示例#3
0
        public static void Execute(Window window, UpdateStatusTaskType ustt, Action action)
        {
            var key = Key(window, ustt);

            if (dic.ContainsKey(key))
            {
                var found = dic [key];
                found.Stop();
                dic.Remove(key);
            }

            var timer = new Timer();

            timer.Enabled  = true;
            timer.Interval = 10000;
            timer.Start();
            timer.Elapsed += delegate(object sender, ElapsedEventArgs e) {
                action();
            };

            action();
            dic.Add(key, timer);
        }
示例#4
0
 protected void UpdateStatus(ListView listView, List <entity.EntityBase> data, UpdateStatusTaskType type, GetStatus getStatus)
 {
     UpdateStatusTaskManager.Execute(window, type, () => {
         data = data.Select(item => {
             var status = getStatus();
             var result = status.Where(n => n.ID == item.ID);
             if (result.Count() > 0)
             {
                 var first        = result.First();
                 var desc         = first.StatusDesc;
                 item.Status      = desc;
                 item.StatusColor = first.StatusTextColor;
                 item.Delay       = first.Delay;
             }
             return(item);
         }).ToList();
         window.Dispatcher.Invoke((Action) delegate {
             listView.DataContext = data;
         });
     });
 }