.NET ThreadPool QueueUserWorkItem Synchronization
- by ikurtz
I am employing ThreadPool.QueueUserWorkItem to play some sound files and not hanging up the GUI while doing so.
It is working but has an undesirable side effect.
While the QueueUserWorkItem CallBack Proc is being executed there is nothing to stop it from starting a new thread. This causes the samples in the threads to overlap.
How can I make it so that it waits for the already running thread to finish running and only then run the next request?
EDIT: I did:
Thread t = new Thread(FireAttackProc(fireResult));
t.Start();
but it gave me some errors. How do I specify a thread method with parameters?