I have some c# code which looks like this:
if (cache[filename] != null) {
return (AppSettings)cache[filename];
}
lock (thisLock)
{
using (StreamReader sr = new StreamReader(filename))
{
instance = (AppSettings)serial.Deserialize(sr);
cache.Insert(filename, instance, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration);
}
}
return (AppSettings)cache[filename];
so, my understanding of a lock, is that once it has become "Unlocked", then the code block will be executes. So in the case of the code above, I'm assuming I'll need another check in the lock code block to see if the object has already been created?
Also how would I check for a deadlock?