Beispiel #1
0
        public async Task WriteInConcurrentObservableCollectionUIThread()
        {
            using (var collection = new ConcurrentObservableCollection <int>())
            {
                _collectionChangedCount = 0;

                collection.CollectionChanged += Collection_CollectionChanged;

                await TaskHelper.RunOnUIThreadAsync(() =>
                {
                    for (int i = 1; i < 10000; i++)
                    {
                        for (int j = 1; j < 10; j++)
                        {
                            collection.Add(i *j);
                        }

                        collection.RemoveAt(collection.Count - 1);
                        collection.Remove(i);
                        collection.Move(0, 6);
                        collection.Insert(0, i *i);
                    }
                }).ConfigureAwait(false);

                Assert.AreEqual(79992, collection.Count);
                Assert.AreEqual(129987, _collectionChangedCount);
            }
        }