public void StartTracking() { _isTracking = true; _task = Task.Run(() => { while (_isTracking) { string strMessage = _bluetoothService.Bluetooth.Read(); if (strMessage != null && int.TryParse(strMessage, out int score)) { int deltaScore = score - _gameStats.Score; _gameStats.Score += deltaScore; _gameStats.AtomicIncrementCoins(deltaScore); } else if (strMessage != null && strMessage.Equals("e") && _isTracking) { //StopTracking(); EndGameEvent?.Invoke(this, false); } } System.Diagnostics.Debug.Print("Score Tracking Ended"); }); }