473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

To MSFT Engineers - others. Help understand Collection Behavior

Hello All
I need some help in understanding some .NET behavior.
I created a collection class derived from CollectionBase and
IBindingList.
I bound a datagrid to the collection.
I added a button and on the click I called RemoveAt(0) . The grid gets
updated properly ( as I am firing ListChanged event from
OnRemoveComplete override of CollectionBase).
Next I created a thread and tried to call myColl.RemoveAt(0) from the
thread, I sometimes get an exception while the datagrid is tring to
paint. It seems as if the removal notice is received by Datagrid after
it tries to paint an item that was already removed .
I don't see any such problems if I says myColl.RemoveAt(
myColl.Count-1).

Any help would be appreciated.

Nov 17 '05 #1
3 929
JimGreen <ji*********@yahoo.com> wrote:
I need some help in understanding some .NET behavior.
I created a collection class derived from CollectionBase and
IBindingList.
I bound a datagrid to the collection.
I added a button and on the click I called RemoveAt(0) . The grid gets
updated properly ( as I am firing ListChanged event from
OnRemoveComplete override of CollectionBase).
Next I created a thread and tried to call myColl.RemoveAt(0) from the
thread, I sometimes get an exception while the datagrid is tring to
paint. It seems as if the removal notice is received by Datagrid after
it tries to paint an item that was already removed .
I don't see any such problems if I says myColl.RemoveAt(
myColl.Count-1).

Any help would be appreciated.


The way I see it, you're changing a bound collection on a different
thread - so the UI is trying to update on that different thread, which
is a bad idea.

I believe you should only update collections which are bound to UI
controls from the UI thread.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Well that sucks. If I have a collection in the back-end does it mean
that I can update the collection from the background thread as more
data arrives?
If what you are saying is true, then I think MS did not understand user
needs.

Nov 17 '05 #3
JimGreen <ji*********@yahoo.com> wrote:
Well that sucks. If I have a collection in the back-end does it mean
that I can update the collection from the background thread as more
data arrives?
Not if the collection is bound to the UI, no.
If what you are saying is true, then I think MS did not understand user
needs.


I agree that it makes data binding harder to work with. It's not
generally too hard to marshal the calls which need to update the bound
data to the UI thread though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

198
by: Sridhar R | last post by:
>From technical point of view, I could not understand the the reasoning behind using Java in major companies. Sure that Python, is used in some, but still Java is considered as a sure-job...
8
by: Generic Usenet Account | last post by:
To settle the dispute regarding what happens when an "erase" method is invoked on an STL container (i.e. whether the element is merely removed from the container or whether it also gets deleted in...
22
by: Alvin Bruney | last post by:
These guys answering posts with MSFT attached to their name, I make the assumption that they are employees of microsoft. My question: Is this a free time activity? Or are they getting paid by MS to...
192
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
7
by: Dale | last post by:
I have a design question. I am creating a custom collection of products. The unique key for the products is productId which is an integer. By default, IndexOf(object obj), when obj is an int,...
9
by: Heck | last post by:
I'm using Visual Studio 2005, but i don't think that's (primarily) where I've gone wrong. I was experimenting, trying, by the way, to move into writing my own iterator so that I can learn,...
2
by: Ken Fine | last post by:
Sorry if this is off-topic but I can't find a better MSFT-managed newsgroup for the question. I'm looking for contact info for Microsoft's campus rep for the University of Washington in Seattle....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.