using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Windows.Forms; using DataBlockHelper.DBHelpers; using DevExpress.XtraEditors.Filtering.Templates; using ICSharpCode.Core; using log4net; using Mesnac.Action.Base; using Mesnac.Action.ChemicalWeighing.LjReport.OpenDoor; using Mesnac.Action.ChemicalWeighing.MinAn; using Mesnac.Action.ChemicalWeighing.RgvPlc; using Mesnac.Basic; using Mesnac.Codd.Session; using Mesnac.Controls.Base; using Mesnac.Controls.ChemicalWeighing; using Mesnac.Controls.Default; namespace Mesnac.Action.ChemicalWeighing.Test { public class TestAction : DatabaseAction, IAction { MCButton mCButton; // LoggingService _log; public void theout(object source, EventArgs e) { mCButton.Text = DateTime.Now.ToString(); } public void Run(RuntimeParameter runtime) { base.RunIni(runtime); //必须调用 var allDb=GetAllControls(); mCButton = allDb.FirstOrDefault(x => x.Name == "MCButton1") as MCButton; System.Timers.Timer t = new System.Timers.Timer(1000);//实例化Timer类,设置间隔时间为10000毫秒; t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件; t.AutoReset = true;//设置是执行一次(false)还是一直执行(true); t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件; } } }