using HZH_Controls.Forms; 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 NewLife; namespace RfidWeb.Frm { public partial class UserMain : UserControl { TimerX _timer; public UserMain() { InitializeComponent(); _timer = new TimerX(TimeState, null, 10, 1000); } private void ucBtnExt5_BtnClick(object sender, EventArgs e) { } private void ucBtnLogin_BtnClick(object sender, EventArgs e) { FormLogin login = new FormLogin(); login.ShowDialog(); } /// 移除过期的缓存项 void TimeState(Object state) { bool isExit = UserManager.IsExit(); this.Invoke(() => { //不存在 if (!isExit) { ucBtnLogin.BtnText = "登录"; ucBtnExt9.BtnText = "无"; } else { var dto = UserManager.GetUser(); ucBtnLogin.BtnText = dto.UserName; ucBtnExt9.BtnText = dto.RoleName; } }); } protected override void OnHandleDestroyed(EventArgs e) { base.OnHandleDestroyed(e); // 在此添加需要手动释放资源的代码 if (null != _timer) { _timer.TryDispose(); } } } }