LableMessage.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using IntelligentControlForsx.MyControls;
  2. using System;
  3. using System.Collections.Concurrent;
  4. using System.Collections.Generic;
  5. using System.Threading;
  6. namespace IntelligentControlForsx.Code
  7. {
  8. public static class LableMessage
  9. {
  10. readonly static ConcurrentDictionary<string, WebfontLable> Labels = new ConcurrentDictionary<string, WebfontLable>();
  11. public static void AddLabel(WebfontLable lable)
  12. {
  13. Labels.TryAdd(lable.Name,lable);
  14. }
  15. public static void DeleteLabel(WebfontLable lable)
  16. {
  17. Labels.TryRemove(lable.Name,out lable);
  18. }
  19. public static void SetLabelTest()
  20. {
  21. Thread T = new Thread(SetLabelText);
  22. T.IsBackground = true;
  23. T.Start();
  24. }
  25. public static void SetLabelText()
  26. {
  27. while (true)
  28. {
  29. Console.WriteLine(Labels.Count);
  30. foreach (WebfontLable l in Labels.Values)
  31. {
  32. if (CommunalTarget.UdpDoubleMemory.ContainsKey(l.TestPointId))
  33. {
  34. Action action1 = () =>
  35. {
  36. l.LableText = CommunalTarget.UdpDoubleMemory[l.TestPointId].ToString("F2");
  37. };
  38. if (l.IsHandleCreated)
  39. l.Invoke(action1);
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }