刚学线程,句柄无效(50分)

  • 主题发起人 主题发起人 scdoudou
  • 开始时间 开始时间
S

scdoudou

Unregistered / Unconfirmed
GUEST, unregistred user!
unit thread;
interface
uses
Classes,ShDocVw;
type
webdata = class(TThread)
protected
procedure Execute;
override;
public
constructor Create();
end;

implementation
constructor webdata.Create();
begin
FreeOnTerminate := True;
end;

procedure webdata.Execute;
begin

end;

end.


unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Menus, StdCtrls, ImgList, StdActns, ActnList,
OleCtrls, SHDocVw, ExtCtrls,thread;
type
TForm1 = class(TForm)
procedure CheckBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
If CheckBox1.Checked = true then
begin
Webdata.create();
end;
end;

end.
 
constructor webdata.Create();
begin
FreeOnTerminate := True;
end;
里面没有调用上层建立函数 inherited create(true);
导致的
=========================================================
其实,可以这样写:
type
webdata = class(TThread)
procedure Execute;
override;
end;
procedure webdata.Execute;
begin
FreeOnTerminate := True;
...................................
end;
 
在构造函数里面,少了点东西吧
是不是应该加上
inherited Create(False)啊?
怎么会句柄无效啊? 不太明白
 
接受答案了.
 
后退
顶部