public void InvokeMsg(object sender, System.Timers.ElapsedEventArgs e) { timerRunner.Stop(); Printer.bill.PrintCore printCore = new bill.PrintCore(); printCore.Done(this); timerRunner.Start(); }
private void refPrt_Click(object sender, EventArgs e) { Printer.bill.PrintCore printCore = new bill.PrintCore(); string text = printCore.findPrt(); this.Invoke(setStatusCallback, new object[] { text }); if (text.IndexOf("查不到名称") < 0) { timerRunner.Start(); toolStripBtnStatus.Text = "服务已开始"; } else { MessageBoxEx.Show("没有打印机"); toolStripBtnStatus.Text = "服务已停止"; } }
private void Print_Load(object sender, EventArgs e) { setTextCallback = new SetTextCallback(SetText); setStatusCallback = new SetStatusCallback(SetStatus); timerRunner.AutoReset = false; //每到指定时间Elapsed事件是触发一次(false),还是一直触发(true) timerRunner.Interval = timerRunnerInterval; // 设置时间间隔 timerRunner.Elapsed += new System.Timers.ElapsedEventHandler(InvokeMsg); Printer.bill.PrintCore printCore = new bill.PrintCore(); string text = printCore.findPrt(); this.Invoke(setStatusCallback, new object[] { text }); if (text.IndexOf("查不到名称") < 0) { timerRunner.Start(); toolStripBtnStatus.Text = "服务已开始"; } else { toolStripBtnStatus.Text = "服务已停止"; } }