Show: Delphi C++
Display Preferences

Handling Exceptions

From RAD Studio
Jump to: navigation, search

Go Up to How To Build Multithreaded Applications

To handle exceptions in the thread function

  1. Add a try...except block to the implementation of your Execute method.
  2. Code the logic such as shown here:
procedure TMyThreadExecute;
begin
  try
    while not Terminated do
      PerformSomeTask;
  except
    {do something with exceptions}
  end;
end;
void __fastcall TMyThread::Execute() 
 {
  try 
   {
    while( !Terminated() ) 
     {
      // perform tasks
     }
   } 
  catch(...) 
   { // catch specific exceptions first
    // exception-handling code
   }
 }

See Also

Personal tools
In other languages
Previous Versions
Assistance