主题:请教多线程,下面程序为什么会出错?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
procedure Button1Click(Sender: TObject);
private
procedure up;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.up;
var s:string;
begin
try
s:=idhttp1.Get( 'http://www.zhcw.com/data-js/nowdata98.js ');出错的地方
except
showmessage( '更新失败! ');
end;
if s < > ' ' then showmessage( '更新成功! ');
end;
procedure TForm1.Button1Click(Sender: TObject);
var tid:dword;
begin
CreateThread(nil,0,@tform1.up,nil,0,Tid);
end;
end.
First chance exception at $7C812A5B. Exception class EAccessViolation with message 'Access violation at address 00482985 in module 'up.exe '. Read of address 00000364 '. Process up.exe (2320)
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
procedure Button1Click(Sender: TObject);
private
procedure up;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.up;
var s:string;
begin
try
s:=idhttp1.Get( 'http://www.zhcw.com/data-js/nowdata98.js ');出错的地方
except
showmessage( '更新失败! ');
end;
if s < > ' ' then showmessage( '更新成功! ');
end;
procedure TForm1.Button1Click(Sender: TObject);
var tid:dword;
begin
CreateThread(nil,0,@tform1.up,nil,0,Tid);
end;
end.
First chance exception at $7C812A5B. Exception class EAccessViolation with message 'Access violation at address 00482985 in module 'up.exe '. Read of address 00000364 '. Process up.exe (2320)