1、我在网上下载一个图片使用了线程但是感觉还是有一种假死机的情况,这是为什么?
2、多有两个过程都要很长的时间才能处理完成,并且它们的结果是相互调用的,请问怎么做这个线程?
3、为什么执行以下的线程会有假死机的情况?怎么解决假死机的情况?
unit UIndustry;interfaceuses
Classes,MandiQ,SysUtils, Rio, SOAPHTTPClient,shellApi,Forms,Windows,RzLstBox;
var
CS:TRTLCriticalSection;
type
TIndustry = class(TThread)
private
RB: TRzListBox ;
Bigtrade:ArrayOfArea;
{ Private declarations } protected
procedure Execute; override;
procedure doFun;
public
Constructor Create(Rlb:TRzListBox); //TempArry 返回的大类信息
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure TIndustry.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ TIndustry }constructor TIndustry.Create(Rlb: TRzListBox);
begin
Rb:=Rlb;
//Bigtrade:=TempArry;
inherited Create(False);
end;
procedure TIndustry.Execute;
begin
Synchronize(doFun);
end;
procedure TIndustry.doFun;
var
Area:ArrayOfArea;
i:integer;
HTTPRIO1: THTTPRIO;
S:String;
begin
Application.Initialize; HTTPRIO1:=THTTPRIO.Create(Application);
Area:=nil;
HTTPRIO1.WSDLLocation:='http://www.163.com/TestWS/services/Test?wsdl';
try
Area:=(HTTPRIO1 as MandiQPortType).getAllTradeBig;
Bigtrade:=Area; //返回数组信息
for i:=0 to High(Area) do
begin
RB.Items.Add(Area[i].name);
end; except
Application.MessageBox('连接Web Service失败!','提示',MB_ICONERROR );
end;
end;end.
2、多有两个过程都要很长的时间才能处理完成,并且它们的结果是相互调用的,请问怎么做这个线程?
3、为什么执行以下的线程会有假死机的情况?怎么解决假死机的情况?
unit UIndustry;interfaceuses
Classes,MandiQ,SysUtils, Rio, SOAPHTTPClient,shellApi,Forms,Windows,RzLstBox;
var
CS:TRTLCriticalSection;
type
TIndustry = class(TThread)
private
RB: TRzListBox ;
Bigtrade:ArrayOfArea;
{ Private declarations } protected
procedure Execute; override;
procedure doFun;
public
Constructor Create(Rlb:TRzListBox); //TempArry 返回的大类信息
end;implementation{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example, Synchronize(UpdateCaption); and UpdateCaption could look like, procedure TIndustry.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }{ TIndustry }constructor TIndustry.Create(Rlb: TRzListBox);
begin
Rb:=Rlb;
//Bigtrade:=TempArry;
inherited Create(False);
end;
procedure TIndustry.Execute;
begin
Synchronize(doFun);
end;
procedure TIndustry.doFun;
var
Area:ArrayOfArea;
i:integer;
HTTPRIO1: THTTPRIO;
S:String;
begin
Application.Initialize; HTTPRIO1:=THTTPRIO.Create(Application);
Area:=nil;
HTTPRIO1.WSDLLocation:='http://www.163.com/TestWS/services/Test?wsdl';
try
Area:=(HTTPRIO1 as MandiQPortType).getAllTradeBig;
Bigtrade:=Area; //返回数组信息
for i:=0 to High(Area) do
begin
RB.Items.Add(Area[i].name);
end; except
Application.MessageBox('连接Web Service失败!','提示',MB_ICONERROR );
end;
end;end.
解决方案 »
- 动态连接数据库问题
- dbExpress(TSimpleDataSet) + MS SQL Server 2000 奇怪的问题('Operation not applicable')
- 大家看看这个:三说软件从业者(2004.01.07 来自:Chinabyte)
- 使WebBrowser进入了编辑后,如何添加表格呢,请帮忙
- 如何在程序中显示、并刷新图片
- 求关于注册表操作得到qq路径的一段代码
- 有delphi的教程(电子版)吗?
- 我是delphi的初学者,怎么样才能实现控件的自动调整大小呢?(在线等待!!)
- CSDN论坛助手又有新的版本了!
- 紧急求助
- 系统MESSAGE类里的const常量WM_USER是什么意思?
- 为何edit的SetFocus不起作用了呢?
var
Industry:TIndustry;
begin
Industry:=TIndustry.Create(RzListBox1);
Timer1.Enabled:=false;
end;
缓解的方法有一些,比如楼上说的设置连接超时等属性,
还有可以使用Sleep方法,空出一些CPU的时间片给其他进程使用,
使用Application。processMessages,让系统在执行中间,有限处理一下消息,再继续执行代码等等