Beispiel #1
0
        public void Play()
        {
            ManualResetEvent start = new ManualResetEvent(false);

            Thread[] threads = new Thread[Tracks.Count];
            for (int i = 0; i < Tracks.Count; i++)
            {
                var track = Tracks[i];
                threads[i] = new Thread(_PlayTrack);
                PlayTrackArgument a = new PlayTrackArgument();
                a.start = start;
                a.track = track;
                threads[i].Start(a);
            }
            Thread.Sleep(100);
            start.Set();
            bool end = false;

            while (!end)
            {
                end = true;
                for (int i = 0; i < threads.Length; i++)
                {
                    end &= !threads[i].IsAlive;
                }
            }
        }
Beispiel #2
0
        private static void _PlayTrack(object _track)
        {
            PlayTrackArgument track = (PlayTrackArgument)_track;

            track.start.WaitOne();
            foreach (var note in track.track.Notes)
            {
                _Beep(note.Frequency, note.Length);
            }
        }
Beispiel #3
0
 public void Play()
 {
     ManualResetEvent start = new ManualResetEvent(false);
     Thread[] threads = new Thread[Tracks.Count];
     for (int i = 0; i < Tracks.Count; i++)
     {
         var track = Tracks[i];
         threads[i] = new Thread(_PlayTrack);
         PlayTrackArgument a = new PlayTrackArgument();
         a.start = start;
         a.track = track;
         threads[i].Start(a);
     }
     Thread.Sleep(100);
     start.Set();
     bool end = false;
     while (!end)
     {
         end = true;
         for (int i = 0; i < threads.Length; i++)
         {
             end &= !threads[i].IsAlive;
         }
     }
 }