unit unitThreadTest;interfaceuses
  Classes;type
  tThreadTest = class(TThread)  private
    { Private declarations }
    procedure cz;
  protected
    procedure Execute; override;
 public
 procedure Terminate;  end;implementationuses Unit1;procedure tThreadTest.Execute;
begin
Synchronize(UpdateCaption);
end;
 procedure tThreadTest.cz
begin
with form1.ADOStoredProc1 do
  begin
    DisableControls;
    try
      Close;
Parameters.ParamByName('@nr').Value:=form1.edit1.Text ;
Parameters.ParamByName('@mm').Value:=form1.combobox1.Text ;
Active:=true;
      Last;
    finally
      EnableControls;
    end;
  end;
end.

解决方案 »

  1.   

    打错了,不是Synchronize(UpdateCaption); 应该是Synchronize(cz); 
      

  2.   

    這個過程在查詢分析中執行要多久?form1.edit1.Text ; 
    form1.edit1.Text ; 
    這二個的值,在線程裏聲明變量直接傳進來,盡量不要在線程裏操作UI方面的東西。即然只是執行一個過程, 不過直接在線程裏創建一個 TStoreproc  來執行過程,執行完釋放掉,不要同界面聯系那麼緊。
      

  3.   

    写这个线程有啥意义呢。Synchronize中的方法就是在主线程中执行的,还不如不要线程直接在主程序中执行cz呢。
      

  4.   

    首先,你要单步执行看你的UpdateCaption是否能运行完毕并跳出.
    其次,你的线程用的这个SynChronize真的没什么意义,SynChronize就是放到主线程执行,跟没写这个线程一样.
    再次,你如果懒写释放代码,线程开始的execute里面加上 FreeOnTerminate := true; 吧