Single-threaded Thread Pool for debugging purposes ?

  • Thread starter Thread starter Richard Chandler
  • Start date Start date
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.
 
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.
 
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 ...
 
Back
Top