首先新建集合绑定到datagrid
ObservableCollection<Person> infos = new ObservableCollection<Person>() {
new Person(){ Sex="man", Age="11", Name="Tom"},
new Person(){ Sex="man", Age="12", Name="Darren"},
new Person(){ Sex="man", Age="22", Name="Jacky"},
new Person(){ Sex="man", Age="21", Name="Andy"}
};
在子线程更新集合后
this.Dispatcher.Invoke(new Action(() =>
{
infos.Add(p);
}), null);
a++;
//重要