Example #1
0
 public void Stop()
 {
     if (_timer != null)
     {
         _timer.Dispose();
     }
 }
Example #2
0
 public void Dispose()
 {
     if (null != _timer)
     {
         _timer.Dispose();
     }
 }
Example #3
0
        // 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);
            }
        }
Example #4
0
        /// <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;
            }
        }
Example #5
0
 public void Dispose()
 {
     _port.Dispose();
     _timer.Dispose();
 }