using Microsoft.AspNetCore.Components; using PrintBarCode.Business; using PrintBarCode.Helper; using PrintBarCode.Model; using SlnMesnac.Redis; using static PrintBarCode.MessageClient; namespace PrintBarCode { public partial class MainForm : Form { public MainForm() { MessageClient.addLogEvent += addLog; InitializeComponent(); addLog("启动监听打印服务成功......"); } private void addLog(string logInfo) { try { // 如果当前调用线程不是创建窗体的线程,使用 Invoke if (this.logList.InvokeRequired) { this.logList.Invoke(new Action(addLog), logInfo); } else { this.logList.Items.Add($"{DateTime.Now}==>{logInfo}"); } } catch (Exception ex) { } } } }