c# 设置一段时间后执行
wpf控件的MouseEnter事件中设置5秒后隐藏控件
System.Timers.Timer timer = new System.Timers.Timer(5 * 1000);//5秒 timer.Elapsed += new System.Timers.ElapsedEventHandler(delegate (object obj, System.Timers.ElapsedEventArgs el) { this.Dispatcher.Invoke((Action)delegate () { timer.Enabled = false; //实现 }); }); timer.AutoReset = false; timer.Enabled = true;