死
死灰
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Buttons, ExtCtrls, DB, ADODB;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TTThread = class(TThread)
private
TADOconn: TADOConnection;
protected
procedure Execute;virtual;
public
constructor Create(ADOConnection: TADOConnection);
end;
var
Form1: TForm1;
Hread: TTThread;
implementation
{$R *.dfm}
{ TThread类的实现 }
constructor TTThread.Create(ADOConnection: TADOConnection);
begin
TADOconn := ADOConnection;
inherited Create(True);
FreeOnTerminate := false;
end;
procedure TTThread.Execute ;{ 执行线程的方法 }
begin
showmessage('开始连接!');
try
TADOconn.Connected := true;
{ 连接 }
showmessage('Connected!')
except
ShowMessage('Connected Error');
{ 连接异常 }
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Hread := TTThread.Create(ADOConnection1);
hread.Resume ;
{这里出错}
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if hread.Suspended then
begin
Hread.Terminate;
{ 销毁之前终止线程执行 }
Hread.Destroy;
end
else
showmessage('没有线程');
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
hread.Terminate;
{ 销毁之前终止线程执行 }
hread.Destroy;
end;
end.
当按下Button1时候运行出错报告:
procedure TForm1.Button1Click(Sender: TObject)
project project1.exe raised exception class EAbstract.Error with message 'Abstract.Error'.Process stopped . use setup or Run to continue.
刚学DELPHI.不要见笑.
线程不能运行.该怎样修改??
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, Buttons, ExtCtrls, DB, ADODB;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TTThread = class(TThread)
private
TADOconn: TADOConnection;
protected
procedure Execute;virtual;
public
constructor Create(ADOConnection: TADOConnection);
end;
var
Form1: TForm1;
Hread: TTThread;
implementation
{$R *.dfm}
{ TThread类的实现 }
constructor TTThread.Create(ADOConnection: TADOConnection);
begin
TADOconn := ADOConnection;
inherited Create(True);
FreeOnTerminate := false;
end;
procedure TTThread.Execute ;{ 执行线程的方法 }
begin
showmessage('开始连接!');
try
TADOconn.Connected := true;
{ 连接 }
showmessage('Connected!')
except
ShowMessage('Connected Error');
{ 连接异常 }
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Hread := TTThread.Create(ADOConnection1);
hread.Resume ;
{这里出错}
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if hread.Suspended then
begin
Hread.Terminate;
{ 销毁之前终止线程执行 }
Hread.Destroy;
end
else
showmessage('没有线程');
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
hread.Terminate;
{ 销毁之前终止线程执行 }
hread.Destroy;
end;
end.
当按下Button1时候运行出错报告:
procedure TForm1.Button1Click(Sender: TObject)
project project1.exe raised exception class EAbstract.Error with message 'Abstract.Error'.Process stopped . use setup or Run to continue.
刚学DELPHI.不要见笑.
线程不能运行.该怎样修改??