WPF invoke的使用


private void UpdateCurrentTimer(object sender, System.Timers.ElapsedEventArgs e)
{
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
textBox_SystemTime.Dispatcher.Invoke(new Action(()=>{
textBox_SystemTime.Text = currentTime.ToString();//记录
}));

}

使用:Dispatcher.Invoke

WPF