直接上代码
public KBehaviour() { //间隔时间 System.Timers.Timer t = new System.Timers.Timer(0.2f * 1000); t.Elapsed += new System.Timers.ElapsedEventHandler(Update); t.AutoReset = true;//一直执行 t.Enabled = true;//自动启动 } protected virtual void Update(object sender, ElapsedEventArgs e) { }