1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using IntelligentControlForsx.MyControls;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace IntelligentControlForsx.Code
- {
- public class WpfMessage
- {
- static List<WpfWindturbine> Wpfs = new List<WpfWindturbine>();
- static object o = new object();
- public static void AddWpf(WpfWindturbine wpf)
- {
- lock (o)
- Wpfs.Add(wpf);
- }
- public static void DeleteWpf(WpfWindturbine wpf)
- {
- lock (o)
- Wpfs.Remove(wpf);
- }
- public static void SetWpfTest()
- {
- Thread T = new Thread(SetWpfText);
- T.IsBackground = true;
- T.Start();
- }
- public static void SetWpfText()
- {
- while (true)
- {
- Console.WriteLine(Wpfs.Count);
- lock (o)
- foreach (WpfWindturbine l in Wpfs)
- {
- if (CommunalTarget.UdpDoubleMemory.ContainsKey(l.TestPointId))
- {
- Action action1 = () =>
- {
- l.State = (int)CommunalTarget.UdpDoubleMemory[l.TestPointId];
- };
- l.Dispatcher.BeginInvoke(action1);
-
- }
- }
- }
- }
- }
- }
|