What's the best way to update an ObservableCollection from another thread?

后端 未结 5 990
终归单人心
终归单人心 2020-12-23 17:06

I am using the BackgroundWorker to update an ObservableCollection but it gives this error:

\"This type of CollectionVi

5条回答
  •  被撕碎了的回忆
    2020-12-23 17:41

    You are using BGW, it was designed to solve your problem. But you'll have to use it properly, update the collection in a ProgressChanged or RunWorkerCompleted event handler. If that's what you are doing then you created the BGW instance on the wrong thread. It has to be done on the UI thread.

提交回复
热议问题