Link to home
Start Free TrialLog in
Avatar of pcox9999
pcox9999Flag for United States of America

asked on

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.  
Avatar of developmentguru
developmentguru
Flag of United States of America image

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.

http://msdn.microsoft.com/en-us/library/ms682608(VS.85).aspx

The pitfalls include:
EXCEPTION_POSSIBLE_DEADLOCK
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).
Avatar of pcox9999

ASKER

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?
ASKER CERTIFIED SOLUTION
Avatar of developmentguru
developmentguru
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.