If you look at the MSDN page for
BindingList[
^] you will see the following at teh bottom:
"Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe."
This means that the threads are interfering with each other! You need to use a
lock
of some form:
BindingList<object> addnew = new BindingList<object>();
System.Threading.Tasks.Parallel.For(0, 1000, i => AddOne(addnew));
MessageBox.Show(addnew.Count.ToString());
}
private void AddOne(BindingList<object> list)
{
lock (list)
{
list.Add(new object());
}
}