using IntelligentControlForsx.MyControls; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Threading; namespace IntelligentControlForsx.Code { public static class LableMessage { readonly static ConcurrentDictionary Labels = new ConcurrentDictionary(); public static void AddLabel(WebfontLable lable) { Labels.TryAdd(lable.Name,lable); } public static void DeleteLabel(WebfontLable lable) { Labels.TryRemove(lable.Name,out lable); } public static void SetLabelTest() { Thread T = new Thread(SetLabelText); T.IsBackground = true; T.Start(); } public static void SetLabelText() { while (true) { Console.WriteLine(Labels.Count); foreach (WebfontLable l in Labels.Values) { if (CommunalTarget.UdpDoubleMemory.ContainsKey(l.TestPointId)) { Action action1 = () => { l.LableText = CommunalTarget.UdpDoubleMemory[l.TestPointId].ToString("F2"); }; if (l.IsHandleCreated) l.Invoke(action1); } } } } } }