多线程不是第一次写了,主要是照顾用户使用的方便,不会让主窗口停顿
这次用到了THashedStringList以及TStringList处理上万条文本行的搜索和更新,也是利用多线程,主窗口只是个进度条走动而已
但是当线程执行以后,主窗口不能拖动也不能获得焦点,只能看到进度条在走动,而其除了主菜单还能显示出来,其他的控件都消失了。等线程执行完毕了才又出来,好像是重新绘制了窗口。
我在线程里面也用了Synchronize来同步这个过程,但是没有任何效果。
请问各位有没有遇到类似的问题?我错在哪里?
下面是线程中的过程,而且我发现处理小数据量的时候一点问题没有,或许是太快感觉不到。
var
TstringTmp01,TstringTmp02:THashedStringList;//
intTmp01,intTmp02,intIndex:integer;//计数器
StrSource,StrCheck:string; //源字符和对比字符
int_Temp:integer;
begin
TstringTmp01:=THashedStringList.Create;
TstringTmp02:=THashedStringList.Create;
TstringTmp01.LoadFromFile('20080227123152.txt');
label1.Caption:=inttostr(TstringTmp01.Count);
TstringTmp01.Sort;
// TstringTmp01.Sorted:=true;
int_Temp:=0;
for intTMp01 := 0 to TstringTmp01.Count-1 do begin
strSource:=TstringTmp01[intTmp01];
if (length(strSource)>0) then begin
while (TstringTmp01.Find(strSource,intTmp02))do
TstringTmp01[intTmp02]:='';
if not TstringTmp02.Find(strSource,int_Temp) then TstringTmp02.Add(strSource);
end;
end;
for intTmp02 := 0 to TstringTmp02.Count - 1 do
memo2.Lines.Add(TstringTmp02[intTmp02]);
TstringTmp01.Free;
TstringTmp02.Free;
这次用到了THashedStringList以及TStringList处理上万条文本行的搜索和更新,也是利用多线程,主窗口只是个进度条走动而已
但是当线程执行以后,主窗口不能拖动也不能获得焦点,只能看到进度条在走动,而其除了主菜单还能显示出来,其他的控件都消失了。等线程执行完毕了才又出来,好像是重新绘制了窗口。
我在线程里面也用了Synchronize来同步这个过程,但是没有任何效果。
请问各位有没有遇到类似的问题?我错在哪里?
下面是线程中的过程,而且我发现处理小数据量的时候一点问题没有,或许是太快感觉不到。
var
TstringTmp01,TstringTmp02:THashedStringList;//
intTmp01,intTmp02,intIndex:integer;//计数器
StrSource,StrCheck:string; //源字符和对比字符
int_Temp:integer;
begin
TstringTmp01:=THashedStringList.Create;
TstringTmp02:=THashedStringList.Create;
TstringTmp01.LoadFromFile('20080227123152.txt');
label1.Caption:=inttostr(TstringTmp01.Count);
TstringTmp01.Sort;
// TstringTmp01.Sorted:=true;
int_Temp:=0;
for intTMp01 := 0 to TstringTmp01.Count-1 do begin
strSource:=TstringTmp01[intTmp01];
if (length(strSource)>0) then begin
while (TstringTmp01.Find(strSource,intTmp02))do
TstringTmp01[intTmp02]:='';
if not TstringTmp02.Find(strSource,int_Temp) then TstringTmp02.Add(strSource);
end;
end;
for intTmp02 := 0 to TstringTmp02.Count - 1 do
memo2.Lines.Add(TstringTmp02[intTmp02]);
TstringTmp01.Free;
TstringTmp02.Free;
解决方案 »
- delphi求知:上下分支树结构的控件
- RemObjects(delphi)怎么连接数据库(SQL)啊?
- dbgrideh的OnDrawColumnCell
- 如何从远程SQLServer导入本地Access
- 求记帐凭证输入控件?
- mdi窗口,如何按F12键调出执行菜单中某项操作?
- 高手帮我解决这个关闭表单的问题???
- 有一些困难的问题
- ■■■■■■■■如何使用flatstyle控件中的flathint▲▲▲▲▲▲▲▲▲▲
- 问题感觉不容易搞定,高手们进来看看。
- 急!!!等待中! delphi 中Variant 如何转换成,一个流,或一个文件??
- 假如有某个程序调用浏览器打开某个网址,如何截获这个消息并解析出网址?
for intTmp02 := 0 to TstringTmp02.Count - 1 do
memo2.Lines.Add(TstringTmp02[intTmp02]);
这几行放在一个procedure里,然后用Synchronize来执行这个procedure。