Nuno Magalhaes <nu************@hotmail.comwrote:
Is there any keyword applicable to a class to make it thread-safe?
Without having to put lock(this){} in all functions?
Putting lock(this) doesn't make it thread-safe.
Thread safety is not a simple matter - you need to carefully consider
threading and various issues when making a class thread-safe. In
particular, think about any code in other classes you call while
holding a lock - if you're not careful, you can easily deadlock.
I'd also recommend against locking on "this" to start with.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too