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.
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.
解决方案 »
- 为什么窗体BorderStyle=bsSizeable 时最大化,anchors设置无效?
- 谁有Delphi7 personal 版本的注册文件呀????急急!!!!!!!!!!!!!!!!!
- 如何在listbox1删除listbox2中有的项?
- [求助]请问在那儿查得到DELPHI的错误处理类里的ErrorCode的含意呀(英文也行)?
- 各位高手Help
- 用Delphi开发的service Application 在win2000下可以安装(用命令行)在Win98下该如何用! 或者是Win98是否支持Service Application
- 求--良师益友(非高手勿进,拒绝灌水)
- 都请进来!!!
- 如何动态改变动态创建的控件的属性,菜鸟求救!!
- 用ADO连接SQLServer,生成的exe文件是否可以脱离Delphi环境运行?
- 关于 fillrect 的两个问题
- 新建DELPHI加油站QQ群 82426159 欢迎新老朋友加入,
form1.edit1.Text ;
這二個的值,在線程裏聲明變量直接傳進來,盡量不要在線程裏操作UI方面的東西。即然只是執行一個過程, 不過直接在線程裏創建一個 TStoreproc 來執行過程,執行完釋放掉,不要同界面聯系那麼緊。
其次,你的线程用的这个SynChronize真的没什么意义,SynChronize就是放到主线程执行,跟没写这个线程一样.
再次,你如果懒写释放代码,线程开始的execute里面加上 FreeOnTerminate := true; 吧