using DB.Entity; using HZH_Controls.Controls; using HZH_Controls.Forms; using NewLife.Caching; using NewLife.Reflection; using NewLife.Threading; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using DB.Service; using Tool; using Tool.Model; namespace RfidWeb.Frm { public partial class UserAlarmShow : UserControl { private TimerX _timer; private HimAlarmManager himAlarmManager = new HimAlarmManager(); public UserAlarmShow() { InitializeComponent(); _timer = new TimerX(TimeState, null, 1000, 1200); } void TimeState(Object state) { var dataTime = DateTime.Now; List< GridViewData > lsList=new List< GridViewData >(); var list = himAlarmManager.GetList(); foreach (var keyValuePair in list) { lsList.Add(new GridViewData() { AlartTime = keyValuePair.Value.ToString("MM-dd HH:mm:ss"), Msg = keyValuePair.Key }); } this.Invoke(() => { int currentFirstVisibleRowIndex = dataGridView1.FirstDisplayedScrollingRowIndex; this.dataGridView1.DataSource=lsList; if (currentFirstVisibleRowIndex > 0) { dataGridView1.FirstDisplayedScrollingRowIndex = currentFirstVisibleRowIndex; } }); // ThreadPoolX.QueueUserWorkItem(UpdateLog); } } }