Sanity check.. Nope I'm gone (TThread Issue)

Wow... four days now looking at a problem that is very obscure will test a
man's sanity.

Application setup

I am working on a DLer replacement for ie4/netscape. The application is
multithreaded where the main application spawns one thread per simultaneous
DL. The Spawned thread creates one instance of HTTPCli (an ICS component) in
the execute and frees that instance before  exiting.

I have implemented Software bandwidth limiting of the DLs. In the OnDocData
event I synchronize to a progress procedure of my own creation. In that
progress procedure I check the current CPS against the desired CPS. If the
current cps is greater than desired I suspend the thread.

The main application thread has a 100ms timer that rechecks the current cps
against the desired and if the cps is below the desired it resumes the

This process works GREAT! Too bad I loose ~10% system and user resources per
sec if the limiting is enabled. I have a Boolean that I can change to
disable / enable the limiting at any time.

Say I enable limiting and loose 50% resources (and still falling) and then
disable limiting while the DL is still in progress. I recover all the lost
resources! Or if I set the main thread timer that checks the threads to say
2-3sec I loose resources slowly and recover them every 5-10sec (without
turning off limiting).

I am not sure that this problem has anything to do with the HTTPCli,and am
starting to think suspending and resuming a thread does something I am not
aware of. At this point any suggestions will be greatly appreciated!

Thanks in advance,


Aaron Hollingsworth