I'm using C# in Visual Studio 2008, and I've run in to a problem that I can't figure out. I've created a thread using ...
... this calls my function that I want spawned on a new thread.
Anyway, the problem is that the code I have running in this new thread plays an audio file all the way through, to completion. What I want to do is to be able to kill the thread at any moment. So, since this thing plays once the thread is spawned, it can't be stopped by some condition variable, the thread needs to be killed. This is the first time I've gotten into threads in C# and can not find a way to do this. I've read numerous times that .Abort() doesn't really work, so, can anyone give me any suggestions on what I can do to kill a spawned thread?
Code:
Thread myThread = new Thread( new ThreadStart(ThreadFunction) ); myThread.Start();
Anyway, the problem is that the code I have running in this new thread plays an audio file all the way through, to completion. What I want to do is to be able to kill the thread at any moment. So, since this thing plays once the thread is spawned, it can't be stopped by some condition variable, the thread needs to be killed. This is the first time I've gotten into threads in C# and can not find a way to do this. I've read numerous times that .Abort() doesn't really work, so, can anyone give me any suggestions on what I can do to kill a spawned thread?
Comment