事件为参数线程怎么写 现在有很多FORM上的查询事件 button1click,button1click,button1click,查询时间比较长经常会出现白屏的情况.想写个通用线程,参数为click事件,只要传参数 button1.click,就可以执行查询动作,大家有什么好的办法. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写个简单的例子吧, 只需要把需要执行的过程(不能带参数)传给线程的ExecuteMethod方法就行。 Circled = True 表示循环执行, False 表示只运行一次。但是还是会出现界面卡的情况,因为要同步VCL,所以如果涉及到界面的一些操作,用线程意义不大。type TWorkThread = class(TThread) private FExecuteMethod: TThreadMethod; FCircled: Boolean; protected procedure Execute; override; public constructor Create; property ExecuteMethod: TThreadMethod read FExecuteMethod write FExecuteMethod; property Circled: Boolean read FCircled write FCircled default False; end;{ TWorkThread }constructor TWorkThread.Create;begin FCircled := False; FExecuteMethod := nil; inherited Create(False);end;procedure TWorkThread.Execute;begin FreeOnTerminate := True; while not Terminated do begin if Assigned(FExecuteMethod) then begin Synchronize(FExecuteMethod); if not FCircled then Break; end; Sleep(10); end;end; 不用线程也无所谓,ado支持异步查询的,设置adoquery的locktype EOF 和 NOT EOF一般是什么情况下使用? 使用Filter来对数据集筛选时 的问题 如何做音效处理处理 “inherited”的问题 请问如和搜索指定目录下的文件 请教高手,什么控件可以判断网络上某台计算机是否在线,还是他的特定端口是否开放? 好奇怪的问题 菜鸟问题集,答对给分 大家遇到过这种情况吗? 求教!!!为什么DB数据库显示数值不正常! 操作系统的像素对控件的位置的影响 CopyToClipboard 使用
Circled = True 表示循环执行, False 表示只运行一次。但是还是会出现界面卡的情况,因为要同步VCL,所以如果涉及到界面的一些操作,用线程意义不大。type
TWorkThread = class(TThread)
private
FExecuteMethod: TThreadMethod;
FCircled: Boolean;
protected
procedure Execute; override;
public
constructor Create;
property ExecuteMethod: TThreadMethod read FExecuteMethod write FExecuteMethod;
property Circled: Boolean read FCircled write FCircled default False;
end;{ TWorkThread }constructor TWorkThread.Create;
begin
FCircled := False;
FExecuteMethod := nil;
inherited Create(False);
end;procedure TWorkThread.Execute;
begin
FreeOnTerminate := True; while not Terminated do
begin
if Assigned(FExecuteMethod) then
begin
Synchronize(FExecuteMethod);
if not FCircled then
Break;
end;
Sleep(10);
end;
end;