0
In my application in C#, I have a list List< float>
where I store data arriving through serial port. With the execution of the application in progress this list begins to get huge. I am not able to clean it because it is a real-time monitoring where I draw graphs with the values of this list and in these graphs are used the 2000 last positions of this list. My question is: How can I clear this list without losing the values of the last 2000 positions? Or maybe, how to make this list temporary, where when I reach N positions is created another list and stored the 2000 last positions of the previous list?
You can use Lynne
– Amadeu Antunes
Certainly the correct solution is another, but without knowing details and we have no way to help. Cleaning doesn’t make much sense, even from what you’re saying you may have competition problems. Maybe you want to use a queue and not a list.
– Maniero
If we provide more information we can give a more objective answer
– Amadeu Antunes
Man, I tried to explain to the max, the code is too big to stick here, but the idea of Maniero seems to work, I hadn’t thought of using a queue
– Felipe Mateus
Like I said, this is an XY problem, you want the solution to the wrong problem.
– Maniero
You are seeking efficiency, and the solutions presented are not inefficient.
– Maniero