This is not a trivial question to answer. What you are showing is a lock during the get operation. This is not necessary, as when you only need read-access there's no need to lock, unless you want read/write

This is not a trivial question to answer. What you are showing is a lock during the get operation. This is not necessary, as when you only need read-access there's no need to lock, unless you want read/write access from multiple threads. Here's what MS has to say about Dictionaries, maybe you need not do anything:

A Dictionary<(Of <(TKey, TValue>)>) can support multiple readers concurrently, as long as the collection is not modified. Even so, enumerating through a collection is intrinsically not a thread-safe procedure. In the rare case where an enumeration contends with write accesses, the collection must be locked during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

I can tell you that code is 100% not what you want. Can you put up the code that is calling that code? You generally need locks when you are *using* the dictionary ... all you have done is locked around returning it to the thing that will use it.

I read data from the dictionary in several diffrent methods, but I do not modify the it when multiple threads are accessing the dictionary .
So then it should be safe?
I do this in about 10 diffrent methods

ServoMotor servo = this._servoList[name];
thre is one time it can create a problem, I have a remove method thats removes a a servo from the list.

can i "safe" this up in any way, can I lock with the object "this" in this methd?

If you do not change the Dictionary while reading from it, you should not need a lock. If you want to change the Dictionary and expect other threads to read at the same time, you will need a lock, but on the whole dictionary. If you do not want to block the other threads while removing elements from the Dictionary, you will have to create your own synchronization scheme for the Dictionary.

one general thing, so if i have a class object and modify values in this object it does not help to lock the "hole" object in a get property, it needs to be protected inside the object it self to get the thread-safe ability
is that right?

One other strange this.
In this property I can't lock all in the set part then then hole application stops
and I get a System.ExecutionEngineException
Thre is one thread that is updating but several threads that are reading, so can I do that then?

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

You are locking on a boolean ... a boolean is a value object... As such it will be boxed and you will be locking on the boxed version (which will be different in both calls...) Create a separate object private object stateLockObject = new object(); and lock on that in both places instead.

How often are you changing items in the dictionary? is performance a concern?

The easiest way to handle this would be to stop returning the dictionary (generally not considered good practice anyways) and instead put methods on your object for the find and remove. Then just lock in both the find and the remove and you are done.

IP addresses can be stored in a database in any of several ways. These ways may vary based on the volume of the data. I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.
…

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…

Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message. In the To field, type your recipient's fax number @efaxsend.com.
You can even send a secure international fax — just include t…

In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…