Give a private field with public read access by the property and a method where this field is written. I use the lock to make a consistent write in a method, but I have no lock in the property. Code inspection warn me with "Inconsistent synchronization on field" hint, but I don't realize what can go wrong? Can anybody explain, is it a correct hint in this situation?

class Foo { private object field; public object Field { get =\> this.field } public void SomeMethod(){ lock(syncRoot) { if () this.field = newValue; } } } 

1 Reply 1

You forgot to mention what language you're using. Editing to add that language to the tags will help experts to notice your question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.