I have a list of objects (musical notes) that are listed in a separate stream when they are played. I do this so that I can respond to the user interface thread.
while a note is playing (as part of an enumeration), how can I allow a new note to be added to the list (without an obvious modified collection exception).
I know that I can copy the list to a temporary list and list it, but I really want the list to grow as the user selects more (and this will happen during the first note, etc.).
psuedo logic as is:
onClick() { Queue.Add(theClickedNote) Queue.Play() <-- on another thread } Play() { if(Playing==true){return ;} foreach(note theNote in Queue) { Note.Play(); Queue.Remove(theNote); } }
As you can see above, each Click event adds a note to the queue and then calls the play method in the queue.
the queue lists the notes and plays each in turn before deleting the note
I hope I explained what I'm trying to make clear?
user1350555
source share