Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Using lock inside class

$
0
0

Hello!

I have some class and 2 method in it. I want to have thread-safety class, so I need to use lock and some lock object.

And question: Can I use 1 lock object for 2 methods? And if I can't - is there any standard ways to have many lock objects without garbadge in class like this:

class SomeClass
{
//...
private object LockerForMethodA;
private object LockerForMethodB;
private object LockerForMethodC;
private object LockerForMethodD;
}


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>