Threadlist's locklist function hangs my program

When attempting to reset my thread manager by looping through the threadlist object that may have pointers to thread objects, my program hangs.  When I set a breakpoint on Threadlist, it comes back as not nil.  When I check Locklist it hangs the debugger.  At runtime it hangs the program.

if ThreadList.LockList.Count > 0 then begin

Is there a way to check at runtime to avoid this?  It is not an error since my try/except handler is never invoked.  It seems like the function is waiting indefinitely for the Locklist function to return.  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would need to see more of your code to have a clue as to what is causing it, but it sounds like the LockList method is waiting until it is able to lock and that never happens.  The ThreadList uses EnterCriticalSection to lock the list.  Read the following link CAREFULLY to see if your code is causing any of the possible pitfalls.

The pitfalls include:
Exceptions that are not intended to be handled
code blocking behavior
(to name a few)

It looks to me like descending a new class from TThreadList would allow you to add a method that would let you wrapper TryEnterCriticalSection so you could get a true or false on whether or not it worked (instead of blocking your code).
pcox9999Author Commented:
I tried calling UnlockList prior to iterating through the list but it did not change the situation.  Maybe I should give you a little context to go along with my question.  My threaded list works inside an ActiveForm application used in Internet Explorer 7.  I have an htm file that calls the ActiveX form.  Works like a charm.  Never fails.  However when called from an aspx application it fails in the same spot, when calling locklist.  I am not sure why there would be a difference.  Thoughts?
It may have to do with the difference between the way the ActiveForm (embedded form in the web page) and the aspx (server side generated web page) are being used (or instantiated).  This can be a terribly tricky thing to debug.  When I need to do this type of debugging I tend to rely heavily on logging.  The way I normally handle the logging is to show both the entry and exit of each method and what parameters are passed.  Looking at the log of each of the two implementations will show you that, as an example, the on create event of the form is called in one instance and not the other (just an example).  Once you have discovered something like that you could make the on create method set a flag during it's execution.  In another event (called by both types) make the call (first thing) if the flag has not been set.  This would make up for the inconsistency.

Now, does it fail consistently as aspx?  Does it fail at the same point of execution every time?  If it does then the logging will be very likely to show you exactly what is happening.

Let me know your thoughts on what I wrote here and I will see if I can do some more to help.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pcox9999Author Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.