public void SaveJudgeDevice(JudgeDevice device) { try { mutex.EnterWriteLock(); EnsureDataLoaded(); devicesById[device.DeviceId] = device; authenticationMap.Clear(); devicesByConnectCode.Clear(); foreach (JudgeDevice existing in devicesById.Values) { if (existing.AuthenticationToken != null) { authenticationMap[existing.AuthenticationToken] = existing.JudgeId; } if (existing.ConnectCode != null) { devicesByConnectCode[existing.ConnectCode] = existing; } } SaveData(); } finally { mutex.ExitWriteLock(); } }
public void SaveJudgeDevice(JudgeDevice device) { lock (this) { devicesById[device.DeviceId] = device; authenticationMap.Clear(); devicesByCode.Clear(); foreach (JudgeDevice existing in devicesById.Values) { if (existing.AuthenticationToken != null) { authenticationMap[existing.AuthenticationToken] = existing.JudgeId; } if (existing.ConnectCode != null) { devicesByCode[existing.ConnectCode] = existing; } } } }