How do I update an ObservableCollection via a worker thread?

前端 未结 4 742
忘了有多久
忘了有多久 2020-11-22 05:23
4条回答
  •  我在风中等你
    2020-11-22 06:05

    With .NET 4.0 you can use these one-liners:

    .Add

    Application.Current.Dispatcher.BeginInvoke(new Action(() => this.MyObservableCollection.Add(myItem)));
    

    .Remove

    Application.Current.Dispatcher.BeginInvoke(new Func(() => this.MyObservableCollection.Remove(myItem)));
    

提交回复
热议问题