public static string?GetGlobalInfo(GlobalInfoKey key) { lock (_globalInfoTableLock) { _globalInfoTable.TryGetValue(key, out var result); return(result); } }
public static void SetGlobalInfo(GlobalInfoKey key, string?value) { lock (_globalInfoTableLock) { if (string.IsNullOrEmpty(value)) { _globalInfoTable.Remove(key); } else { _globalInfoTable[key] = value !; } } }
public static void SetGlobalInfo(GlobalInfoKey key, string?value) { lock (_globalInfoTableLock) { if (string.IsNullOrEmpty(value)) { _globalInfoTable.Remove(key); } else { _globalInfoTable[key] = value !; } } // Triggering the event outside of the lock to avoid potential deadlock // if the handler will cause another change of a global state. // null sender is a common case for static events. GlobalInfoChanged?.Invoke(sender: null, new GlobalInfoChangedEventArgs(key, value)); }
public GlobalInfoChangedEventArgs(GlobalInfoKey key, string?value) { Key = key; Value = value; }