String's in C# are immutable and threadsafe. But what when you have a public getter property? Like this:
public String SampleProperty{
get;
private set;
}
If we have two threads and the first is calling 'get' and the second is calling 'set' at the "same" time, what will happen?
IMHO the set must made a lock to be thread-safe like this:
private string sampleField;
private object threadSafer = new object();
public String SampleProperty{
get{ return this.sampleField; }
private set{
lock(threadSafer){
sampleField = value;
}
}
}