Single-threaded Thread Pool for debugging purposes ?

R

Richard Chandler

Does anyone know whether it's possible to make the ThreadPool only have one
thread in it ?

I have a highly parallel engine where many objects can be in many states ...
where work carried out at each state is done with a QueueUserWorkItem.

I need to debug the system to make sure it works properly in for each
individual object.

Instead of kicking off a WaitCallback delegate ... I'm invoking it directly
(DynamicInvoke) when I'm in Single Threaded Debug mode ... but this does
alter the behaviour of my code slightly (consuming more stack, functions not
exiting until 9 levels of work are done, rather than each one finishing
before the next starts as with multithreaded environment).

So in short, does anyone know how to make the ThreadPool only have one
thread in it ?

Thanks if you can help,

R.
 
R

Richard Chandler

Have since looked at RegisterWaitForSingleObject ... this might help me ...
if I pile up all the start object requests all waiting for an AutoResetEvent
and Set the event at the completion of each object ... all the subsequent
QueueUserWorkItems for the first object will be done in priority to starting
other objects ... yay !

(I think)

R.
 
R

Richard Chandler

Wow .. cool .. the threadpool is now only running one thread of execution
when I want it to ... cool !

You probably think I'm mad ... but it's important to debug as close to
production code as possible ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top