asp.net - Application Variable in .NET - Locking is needed with Concurrent collections? -


when using applications variables can lock them avoid 2 threads updating same variable @ same time. let's have application variable holds concurrent collection (which thread-safe). need use .lock statement?

for example, necessary?

try   application.lock()   directcast(application("test"), concurrent.concurrentdictionary(of string, string)).tryadd("hello", "world")    application.unlock() end try 

or fine?

directcast(application("test"), concurrent.concurrentdictionary(of string, string)).tryadd("hello", "world") 


Comments