public void Stop() { if (_timer != null) { _timer.Dispose(); } }
public void Dispose() { if (null != _timer) { _timer.Dispose(); } }
// duration is expressed in eighth notes at 120 beats/min private void PlayTone(int tone, int duration) { if (_noteTimer != null) { // A new note kills the previous one _noteTimer.Dispose(); _noteTimer = null; BrainPad.Buzzer.Stop(); _firmata.SendSysex((byte)ExtendedMessageCommand.ActionCompleted, new[] { _toneWaitId0, _toneWaitId1 }); } if (tone < _notes.Length) { if (tone != 0) // a tone of 0 is a rest - we don't play anything, we just wait it out { BrainPad.Buzzer.PlayFrequency(_notes[tone]); } _noteTimer = new ExtendedTimer( EndTone, null, 250 * duration, System.Threading.Timeout.Infinite); } }
/// <summary> /// Releases used resources. /// </summary> public void Dispose() { if (updateTimer != null) { updateTimer.Dispose(); updateTimer = null; } // Shut down socket first, so the ReceiveFrom method in thread gets unblocked if (socket != null) { socket.Close(); socket = null; } if (thread != null) { terminate = true; thread.Join(); thread = null; } }
public void Dispose() { _port.Dispose(); _timer.Dispose(); }