我想在线程中发生的所有 Socket Error都捕捉起来 记录在一个件中procedure tfrmmain.LogException(Sender: TObject; E: Exception);
var
  Filename: string;
  LogFile: TextFile;
begin
  Filename := ChangeFileExt (Application.Exename, '.log');
  AssignFile (LogFile, Filename);
  if FileExists (FileName) then
    Append (LogFile) // open existing file
  else
    Rewrite (LogFile); 
   try
     Writeln (LogFile, DateTimeToStr (Now) + ':' + E.Message);
    if not CheckBoxSilent.Checked then
      Application.ShowException (E);
  finally
      CloseFile (LogFile);
  end;
end;上述代码就是不能捕捉线程Exception

解决方案 »

  1.   

    線程的錯誤只能自己處理吧, 感覺你那個函數, 只有處理主線程的Excepiton!!!
      

  2.   

    再想问一下
       如何控制一个线程的执行超时 我就要kill掉
      

  3.   

    这样处理的 达到了效果 但不知有什么负做用没
    在 Tmythread 中try
      ....
     except
           on E : Exception do
              begin
                tLogException(nil,E);  //主窗口中的一个过程它的内容与LogException一样  
               end;
          end;