ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Code inspection: Inconsistent synchronization on field

Last modified: 11 February 2024

This code inspection warns you about fields being used both with and without locking, thus helping you detect potential problems with thread safety. Here is an example:

The inspection is not triggered on const fields and in private methods that have no synchronization inside but are always used from synchronized contexts.