private volatile int _countUntilTen = 0; if (_countUntilTen < 10) { ... }
... private volatile static Dictionary<string, string> _cache = new Dictionary<string, string>(); private void UpdateInAnotherThread (){ ... } public string ReadCache(string key){ if(!_cache.ContainsKey(key)){throw new Exception();} return _cache[key]; } ...