Multithreaded exception: A ItemsControl is inconsistent with its entry source

Source: Internet
Author: User


This two days to write a WPF client, bind a ObservableCollection data source for the DataGrid, but it is so simple a thing, after the completion of the execution occurs bug,bug page as follows:


Find problems and solutions with Google. The problem is that in a multithreaded environment, the update operation on the data source collection conflicts with the display of the UI thread. How to solve? Look underneath.


void Updateitems () {//retrieveditems is the data of the received from the    service    foreach (object item in Retrievedite ms)        Dispatcher.begininvoke (Dispatcherpriority.background, New Parameterizedthreadstart (AddItem), item);    } void AddItem (Object item) {    Observablecollection.add (item);}

Just use this asynchronous update, OK, the bug is done.

SOURCE Link here: Http://stackoverflow.com/questions/2505492/wpf-update-binding-in-a-background-thread


Finally sigh, the Chinese resources is very little Ah, Google problems or to use English, the above question with the following sentence to search

an ItemsControl are inconsistent with its items source, it will be able to search a bunch of solutions on the StackOverflow.































Multithreaded exception: A ItemsControl is inconsistent with its entry source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.