|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with generic List<>Hi,
I have a problem using the generic List... in fact, it seems like a bug in the framework, but I can't find why... I have an application that runs in the tasktray (not as a service), after a while (random, but seems like approx a month) I receive an exception saying ArgumentOutOfRangeException (I attached an image showing all the data) the application is trying to get the element at the index 0 (it varies... the other day it was 17) in a collection that contains 23 elements, so it should work fine... None of the elements is null, but I receive the exception anyways... Can someone confirm me it's a bug in the framework? can I report it to MS? Thanks ThunderMusic [attached file: ArgumentOutOfRange Not out of range.JPG]
Show quote
"ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message Is the list being accessed by more than one thread? If so, that's likely news:u5wt4JlCHHA.1196@TK2MSFTNGP02.phx.gbl... > Hi, > I have a problem using the generic List... in fact, it seems like a bug > in the framework, but I can't find why... > > I have an application that runs in the tasktray (not as a service), after > a while (random, but seems like approx a month) I receive an exception > saying ArgumentOutOfRangeException (I attached an image showing all the > data) the application is trying to get the element at the index 0 (it > varies... the other day it was 17) in a collection that contains 23 > elements, so it should work fine... None of the elements is null, but I > receive the exception anyways... Can someone confirm me it's a bug in the > framework? can I report it to MS? the source of your intermittent error. If you're accessing a List<T> from multiple threads, you need to use some form of thread synchronization to coordination access to the list. -cd no, the application is strictly single threaded... A made sure it was
because no multithreading is needed at all...(except the fact that .NET starts multiple threads for one application) But I'll try to lock the collection to make sure is thread-safe... just in case..... Thanks for the tip ThunderMusic Show quote "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam> wrote in message news:eUIsPumCHHA.4680@TK2MSFTNGP04.phx.gbl... > "ThunderMusic" <NoSpAmdanlatathotmaildotcom@NoSpAm.com> wrote in message > news:u5wt4JlCHHA.1196@TK2MSFTNGP02.phx.gbl... >> Hi, >> I have a problem using the generic List... in fact, it seems like a bug >> in the framework, but I can't find why... >> >> I have an application that runs in the tasktray (not as a service), after >> a while (random, but seems like approx a month) I receive an exception >> saying ArgumentOutOfRangeException (I attached an image showing all the >> data) the application is trying to get the element at the index 0 (it >> varies... the other day it was 17) in a collection that contains 23 >> elements, so it should work fine... None of the elements is null, but I >> receive the exception anyways... Can someone confirm me it's a bug in >> the framework? can I report it to MS? > > Is the list being accessed by more than one thread? If so, that's likely > the source of your intermittent error. If you're accessing a List<T> from > multiple threads, you need to use some form of thread synchronization to > coordination access to the list. > > -cd > > |
|||||||||||||||||||||||