Raleted to:
please consider this code:
public static class SomeClass { public static void Method1(string key, int item) { //Some Work } public static DataTable Method2() { //Some Work } .... If I want to use this class in Asp.Net application from performance point of view does it need separate lock object for every methods like this:
public static class SomeClass { private Object thisLock1 = new Object(); public static void Method1(string key, int item) { lock(thisLock1) { //Some Work } } private Object thisLock2 = new Object(); public static DataTable Method2() { lock(thisLock2) { //Some Work } } ....
Itemscollection. Once it's returned, the collection can be modified while the caller is using it. If you must return all items, return a copy of the collection instead. And yes, that copy operation would have to be locked.keyproperty in yourItemclass, use aDictionary(or rather aConcurrentDictionary)