1,非UI线程使用控件(Scroview滚动条永远显示最下面最新数据方法):
listbox.Dispatcher.Invoke(new Action(() =>
{
listbox.Items.Add( ": 失去连接!");
double d = listbox.ActualHeight;
ScroView.ScrollToVerticalOffset(d);
}));
2,wpf窗口关闭前的事件(退出线程或者监听,防止退出时卡死):
this.Closing += Window_Closing;
private void Window_Closing(object sender, CancelEventArgs e)
{
try
{
Environment.Exit(0);
listener.Stop();
}
catch (Exception)
{
}
}
3,时间控件使用(备忘):
System.Timers.Timer timer = new System.Timers