ASP.NET Core singleton with a thread-safe property that can be changed Thanks to ASP.NET Core dependency injection, there's no need to follow the Singleton pattern; any class will do.
What I want to do is to have a class that will store a value that'll be used by another methods inside the app. A specific class is in charge of updating this value. What I'm concerned is the problem of a thread reading the value while the specific class updates it, given that I haven't done enough concurrency to feel confident.
So I came up with this. Is it correct for what I want it to do?
public class DynamicValueStore
{
    private readonly object _lock_obj;
    
    private string _value;

    public string Value
    {
        get 
        {
            lock (_lock_obj)
            {
                return _value;  
            }
        }
    }

    public DynamicValueStore()
    {
        _lock_obj = new object();
        _value = string.Empty;
    }

    public void UpdateValue(string value)
    {
        if (string.IsNullOrWhiteSpace(value))
        {
            throw new ArgumentNullException(nameof(value));
        }
        lock (_lock_obj)
        {
            _value = value;
        }
    }
}
```
That will lock it down for sure.  If you know you will have more reads then writes, which is common, you should look at the ReaderWriterLockSlim class.   What you have will only allow one read and one write and they all queue up in line waiting their turn.  The ReaderWriterLockSlim class will still only allow one write at a time but allow multiple reads at a time.