unprotected access to member in property get

Posted by Lenik on Stack Overflow See other posts from Stack Overflow or by Lenik
Published on 2010-06-01T19:11:20Z Indexed on 2010/06/01 19:13 UTC
Read the original article Hit count: 138

Filed under:
|

I have a property

    public ObservableCollection<string> Name
    {
        get
        {
            return _nameCache;
        }
    }

_nameCache is updated by multiple threads in other class methods. The updates are guarded by a lock. The question is: should I use the same lock around my return statement? Will not using a lock lead to a race condition?

© Stack Overflow or respective owner

Related posts about c#

Related posts about multithreading