Link to home
Start Free TrialLog in
Avatar of 1750
1750

asked on

crashed threads

how can I tell if a thread has crashed?

if Im running an additional thread, is there an easy way to tell if the thread has crashed?

for that matter, what actually happens when a thread crashes?  in my App, the other threads seem to carry on and not notice that the thread is dead, except when some task that the thread was supposed to perform doesnt happen.
if this thread crashes, somehow the other threads need to know, and shut themselves down gracefully.

thanks

Ben

ASKER CERTIFIED SOLUTION
Avatar of rwilson032697
rwilson032697

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
Avatar of 1750
1750

ASKER

would putting a try..finally inside the execute method work?  ie:

procedure TMyThread.Execute;
begin
  try
    .
    .
  finally
    if not terminated then IveCrashed:=True;
  end;
end;

or would I need to use try..except?  Ive never quite understood the difference between the two.  




Avatar of 1750

ASKER

oops!  if forgot to include:

Brain.Engage;

I do know the difference between try..finally and try..except!

ive tried the try..finally scenario, and it doesnt seem to work.

any ideas?


The try except scenario should work if the crash is hapenning due to an exception. However, it may just be getting into an inifinite loop, or is blocked waiting access to a semaphore or mutex which it is never granted etc..

The actual crash might be happening the the synchronise method in which case it is occurring in the main VCL thread (which might explain whay a try..finally doesn't seem to work...). Though I would have thought this would still generate an exception (which it might but is being caught and ignored...)

Raymond.

Avatar of 1750

ASKER

thanks