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

Thread Safety for collections

How does dotnet handles thread safety of Collections ?

I derived some classes from CollectionBase and DictionaryBase, and created
some typed Add, Remove methods to call typeless based Add, Remove methods.
Do I have to handle the locking myself ?

If one thread gets the IEnumerator, and iterate it. What happens when
another thread wanna add things to the collection ?

Thanks
Jack
Nov 17 '05 #1
2 3201
I got it from MSDN. Only type operations are thread safe, and instance
operations are not thread safe. We have to synchronize the calls ourselves.

However, I've another question:
What's the differece between using Hashtable or implementing collections
based on DictionaryBase, in terms of performance and memory usage?
I need a collection class that can some itmes, say 10000 but should retrive
fast with its key.

"Jack" <jack@no_spam.com> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
How does dotnet handles thread safety of Collections ?

I derived some classes from CollectionBase and DictionaryBase, and created
some typed Add, Remove methods to call typeless based Add, Remove methods.
Do I have to handle the locking myself ?

If one thread gets the IEnumerator, and iterate it. What happens when
another thread wanna add things to the collection ?

Thanks
Jack

Nov 17 '05 #2
I got it from MSDN. Only type operations are thread safe, and instance
operations are not thread safe. We have to synchronize the calls ourselves.

However, I've another question:
What's the differece between using Hashtable or implementing collections
based on DictionaryBase, in terms of performance and memory usage?
I need a collection class that can some itmes, say 10000 but should retrive
fast with its key.

"Jack" <jack@no_spam.com> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
How does dotnet handles thread safety of Collections ?

I derived some classes from CollectionBase and DictionaryBase, and created
some typed Add, Remove methods to call typeless based Add, Remove methods.
Do I have to handle the locking myself ?

If one thread gets the IEnumerator, and iterate it. What happens when
another thread wanna add things to the collection ?

Thanks
Jack

Nov 17 '05 #3

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

Similar topics

2
by: David | last post by:
Hi guys I have in my application many collections (HashTable and ArrayList)loaded with configuration data, that means they are loaded at startup and then they are accessed only for read-only...
2
by: Steve Jorgensen | last post by:
I frequently find myself wanting to use class abstraction in VB/VBA code, and frankly, with the tacked-on class support in VB/VBA, there are some problems with trying to do that and have any...
4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
9
by: Alexander Fleck | last post by:
Hi, I' ve to make a software module thread safe. I know how to realize that and what' re the main topics of thread safety. But I don' t know how thread safety can be tested. I read about a test...
4
by: Anders Borum | last post by:
Hello! I'm am currently working on making a central cache component threadsafe, and was looking at the synchronized implementation of the Hashtable. I was wondering why you'd really want to...
0
by: Jack | last post by:
How does dotnet handles thread safety of Collections ? I derived some classes from CollectionBase and DictionaryBase, and created some typed Add, Remove methods to call typeless based Add, Remove...
4
by: Warren Sirota | last post by:
Hi, I've got a method that I want to execute in a multithreaded environment (it's a specialized spider. I want to run a whole bunch of copies at low priority as a service). It works well running...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
7
by: intrader | last post by:
I have the following small classes: //----------------code--------------- using System; using System.Collections.Generic; using System.Text; namespace ValidatorsLibrary { public class...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.