public IndexForm() { #region 检查版本升级 #if !DEBUG Task.Run(async() => { while (true) { //检查版本升级 await CheckUpgradeAsync(); await Task.Delay(1000 * 60 * 60 * 1);//一小时 } }); #endif #endregion InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; FormBorderStyle = FormBorderStyle.FixedSingle; //加载模拟服务的历史数据 DataPersist.LoadData(); #region 初始化设置上次选择的tab var tabName = GetTabName(); if (!string.IsNullOrWhiteSpace(tabName)) { foreach (TabPage item in tabControl1.TabPages) { if (item.Name == tabName?.Trim()) { //设置上次选择的tab tabControl1.SelectedTab = item; } //还未实现,先隐藏 else if (item.Name == "OmronFinsTcp") { tabControl1.TabPages.Remove(item); } //加载用户控件 SelectedTab(item); } } //切换到上次选择的Tab SelectedTab(tabControl1.SelectedTab); #endregion Task.Run(async() => { await Task.Delay(1000 * 60 * 1);//1分钟自动保存一次 DataPersist.SaveData(); }); }
public IndexForm() { InitializeComponent(); StartPosition = FormStartPosition.CenterScreen; FormBorderStyle = FormBorderStyle.FixedSingle; DataPersist.LoadData(); SelectedTab(tabControl1.SelectedTab); Task.Run(async() => { await Task.Delay(1000 * 60 * 1);//1分钟自动保存一次 DataPersist.SaveData(); }); }
private void IndexForm_FormClosing(object sender, FormClosingEventArgs e) { DataPersist.SaveData(); }