using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mesnac.Action.Feeding.Qingquan.LockScales { /// /// 锁秤业务服务 /// public class LockScaleService { #region 字段定义 private System.Timers.Timer _timer = null; #endregion #region 单例实现 private static LockScaleService _instance = null; private LockScaleService() { } public static LockScaleService Instance { get { if (_instance == null) { _instance = new LockScaleService(); } return _instance; } } #endregion #region 启动定时器运行服务 /// /// 启动定时器运行服务 /// public void Start() { if (this._timer == null) { Global.PublicVar.Instance.G_DownloadSL = 1; //下传送胶信号标志 this._timer = new System.Timers.Timer(); this._timer.Interval = 2000; this._timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed); this._timer.Start(); } } #endregion #region 停止定时器运行服务 /// /// 停止定时器运行服务 /// public void Stop() { if (this._timer != null) { this._timer.Stop(); this._timer.Dispose(); this._timer = null; } } #endregion #region 定时器服务事件处理 /// /// 定时器服务事件处理 /// /// /// protected void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { lock (String.Empty) { CheckBarcodeHelper.CheckBarcode(); //检查条码 } } #endregion } }