N
netfire_fly
Unregistered / Unconfirmed
GUEST, unregistred user!
不好意思,我分不多,只能给这么多
procedure MultiSearchThread.Execute;
var multithread:TMainSearchThread;
//需要调用次级线程
i:integer;
begin
Form1.PFilelist.Cursor:=crHourGlass;
//for i:=0 to 5do
begin
MultiThread:=TmainSearchThread.Create(true);
MultiThread.FreeOnTerminate:=true;
MultiThread.Resume ;
if Terminated then
exit;
Form1.pFileList.cursor:=CrDefault;
end;
end;
还有一个次一级的线程 TMainSearchThread
procedure TmainSearchThread.Execute;
var LServer:TstringList;
LUsers:TstringList;
LUResource:TstringList;
n,i,j,k{,m}:integer;
WorkGroupCount,Usercount:Integer;
item:TListItem;
Tempuserstr:string;
SRFile:TSearchRec;
NetDir,TempDir:string;
FileAttr:integer;
curp:Tpoint;
searchers:array[0..50] of TSearchUserThread;
DevGroup:integer;
LeftGroup:integer;
begin
if Terminated=true then
exit;
begin
// TGroupList:=TstringList.Create ;
initializeCriticalSection(g_critical);
With Form1do
begin
pFilelist.Clear ;
try
Lserver:=TstringList.Create ;
LUsers:=TstringList.Create ;
LUResource:=TstringList.Create
//--------------------------------------------
do
something
//----------------------------------------------
finally
Lserver:=TstringList.Create ;
LUsers:=TstringList.Create ;
LUResource:=TstringList.Create;
Screen.cursor:=crDefault;
end;
//end try
end;
//end with
end;
//
end;
我的停止方法 //一点都不管用,无法中间终止线程,老是句柄无效.而且总是线程也无法终止
procedure TForm1.SpstopClick(Sender: TObject);
var Returnword;
begin
Searchf.Stop ;
spgo.Enabled :=true;
BitBtn1.Enabled:=true;
if MainThread=nil then
exit
else
begin
MainThread.Suspend;
TerminateThread(MainThread.Handle,Return);
MainThread.Free;
//MainThread.Terminate;
//MainThread.Free;
end;
end;
procedure MultiSearchThread.Execute;
var multithread:TMainSearchThread;
//需要调用次级线程
i:integer;
begin
Form1.PFilelist.Cursor:=crHourGlass;
//for i:=0 to 5do
begin
MultiThread:=TmainSearchThread.Create(true);
MultiThread.FreeOnTerminate:=true;
MultiThread.Resume ;
if Terminated then
exit;
Form1.pFileList.cursor:=CrDefault;
end;
end;
还有一个次一级的线程 TMainSearchThread
procedure TmainSearchThread.Execute;
var LServer:TstringList;
LUsers:TstringList;
LUResource:TstringList;
n,i,j,k{,m}:integer;
WorkGroupCount,Usercount:Integer;
item:TListItem;
Tempuserstr:string;
SRFile:TSearchRec;
NetDir,TempDir:string;
FileAttr:integer;
curp:Tpoint;
searchers:array[0..50] of TSearchUserThread;
DevGroup:integer;
LeftGroup:integer;
begin
if Terminated=true then
exit;
begin
// TGroupList:=TstringList.Create ;
initializeCriticalSection(g_critical);
With Form1do
begin
pFilelist.Clear ;
try
Lserver:=TstringList.Create ;
LUsers:=TstringList.Create ;
LUResource:=TstringList.Create
//--------------------------------------------
do
something
//----------------------------------------------
finally
Lserver:=TstringList.Create ;
LUsers:=TstringList.Create ;
LUResource:=TstringList.Create;
Screen.cursor:=crDefault;
end;
//end try
end;
//end with
end;
//
end;
我的停止方法 //一点都不管用,无法中间终止线程,老是句柄无效.而且总是线程也无法终止
procedure TForm1.SpstopClick(Sender: TObject);
var Returnword;
begin
Searchf.Stop ;
spgo.Enabled :=true;
BitBtn1.Enabled:=true;
if MainThread=nil then
exit
else
begin
MainThread.Suspend;
TerminateThread(MainThread.Handle,Return);
MainThread.Free;
//MainThread.Terminate;
//MainThread.Free;
end;
end;