TTestThread = class(TThread)
.........省略
Var
T1:TTestThread;
.........省略
.........省略
procedure zantingxc();
Begin
SuspendThread(T1); //挂起线程 这样会提示Incompatible types 'cardinal'and 'TTestThread'
End;换种方式:
procedure zantingxc();
Begin
T1.Suspend; //挂起线程 这样F9编译可以通过,当调用这个过程时会弹出错误。
End;//****************************请教详细正确的在线程运行时暂停和继续线程的方法******************************请教详细正确的在线程运行时暂停和继续线程的方法,在线等,或者加QQ19六97肆539,谢谢分散完了,请求大家帮帮忙
.........省略
Var
T1:TTestThread;
.........省略
.........省略
procedure zantingxc();
Begin
SuspendThread(T1); //挂起线程 这样会提示Incompatible types 'cardinal'and 'TTestThread'
End;换种方式:
procedure zantingxc();
Begin
T1.Suspend; //挂起线程 这样F9编译可以通过,当调用这个过程时会弹出错误。
End;//****************************请教详细正确的在线程运行时暂停和继续线程的方法******************************请教详细正确的在线程运行时暂停和继续线程的方法,在线等,或者加QQ19六97肆539,谢谢分散完了,请求大家帮帮忙
type
TTestThread=class(TThread)
...
public
constructor Create(CreateSuspended:Boolean);
...constructor TTestThread.Create(CreateSuspended:Boolean);
begin
FreeOnTerminate:=true;
inherited Create(CreateSuspended);
end;procedure TTestThread.Execute;
begin
if not Terminated then
...
end;窗体中:
uses ...
var
h:TTestThread; 以下用4个button,每个1句代码
h:=TRearThread.Create(true); //创建,有其它参数就传参数
h.Resume; //激活
h.Suspend; //挂起
h.Terminate; //结束
你可用 TEvent,TMutex等对线程进行控制。
可以看万一的博客,上面有多线程入门。