.NET ThreadPool QueueUserWorkItem Synchronization

Posted by ikurtz on Stack Overflow See other posts from Stack Overflow or by ikurtz
Published on 2010-03-28T18:17:53Z Indexed on 2010/03/28 19:33 UTC
Read the original article Hit count: 612

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about synchronization