473,382 Members | 1,362 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,382 software developers and data experts.

ArrayList to List<myType> and item disposal

Hi All,
Suppose you need to release unmanaged resources when you remove an
item from a colletction.

We are now using an override of the ArrayList.Remove() method that
dows the job.

We wanted to move to generics but the List<Tcollection does not
feature any virtual method.

How should we proceed?

We need to release unmanaged resources immediately and cannot rely on
the GC delayed cleanup.
Thanks!

Alberto
Jan 28 '08 #1
5 1320
Collection<Tprovides the necessary virtual methods - but it will be
up to your code to ensure that nothing else (other than the
collection) is still using it when it gets disposed.

Marc
Jan 28 '08 #2
Thanks a lot Marc, it is exaclty what I am looking for !!!!

Jan 29 '08 #3
Nice, but in many cases we resize it to 100,000 and use 90,000. In
your sample this is not possible. In addition resizing would clear the
array contents. I hope that something is changed in .NET 3.5. Do you
know if Collection<Tin .NET 3.5 is more capable?

Thanks again,

Alberto
Jan 30 '08 #4
Thanks so much Marc, you are great! Where did you learn these tricks?

I'll try again an let you know.

Thanks!

Alberto
Feb 1 '08 #5
Thanks so much Marc
No problem; I'm glad it helped
Where did you learn these tricks?
Trial and error (mainly error...); and by watching / asking questions
on forums like this.

Marc

Feb 1 '08 #6

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

Similar topics

4
by: KC | last post by:
Could some one explain to me the casting rules for sending generic lists, ex. List<Person>, to a function that accepts List<object>? I cannot get the following easy-cheesy app to work. I get the...
17
by: Rainer Queck | last post by:
Hi NG, one more question about thread safety of generic lists. Let's assume a generic list: List<MyTyp> aList = new List<MyType>(); Would it be a problem if one thread removes elements from...
6
by: A.Rocha | last post by:
Hi, I need save to text file a List<type>, but i dont wont serialize. // List<mytypemyList = new List<mytype>(); anyone can help me? --
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...

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.