3

Ending a worker thread that has its own message loop

view full story
linux-howto

http://www.daniweb.com – I am working on a really fun project. I have written much of a program that lets you use a RockBand or GuitarHero drum kit to play drum sounds on your PC, record, playback, ect. I have decided conclusively as I add features I need more than just a gui thread calling async play sound methods. I need extensive threading here and for the most part I know what to do. But I have a Metronome class that uses async media timer and playsound methods. but still has trouble being accurate if something else on the form slows down the message loop. So I have started a new thread that uses Application.Run() to start that thread with its own message loop. then creates the timer class, starts it and hooks up an event. then in the event it calls the playsoundAsync method. So now I have 2 problems, How do I safely change the timer objects Interval property from the GUI thread? and then How do I safely stop this type of thread? the standard while loop practice is useless here because I am using a MessageLoop to process events. I have most often used threading to do some finite task that will return when its done. This is a new practice for me using threads to insure an accurate "on-beat" playing of audio. I have lots of code bouncing around in my head, I just want some insight before I make a mess. Searching the net has come up with frustrating results, Conflicting forum posts, and indirect answers. Thanks. (General)