F
fengyhf
Unregistered / Unconfirmed
GUEST, unregistred user!
通过建立线程,调用一个画图的类画图,画图的的工具通过teeChart来完成。
不知道TChart是否与Thead有冲突?
在我做的demo中,调用45个线程,运行大概2个小时后,线程就剩下3个甚至是1个。
通过调试工具跟踪发现,Tchart对象在销毁画图类的时候。
判断SeriesCount出错。
我把所有分数送出,请高手指教。
下面部分代码:
线程画图:
procedure TQueryThread.Execute;
var
loDrawChart : TDrawControlChart;
begin
{ Place thread code here }
loDrawChart:=nil;
while True do
begin
if Terminated then
exit;
try
try
//画图动作begin
loDrawChart := TDrawControlChart.CreateWithParam;
loDrawChart.DrawControlChart;
loDrawChart.AdapterConrelChartStyle(1,loPriTee,loSecTee);
synchronize(SetChartTee); //同步VCL
//画图动作end
//调用成功
except
//调用失败
end;
finally
FreeAndNil(loDrawChart);
end;
sleep(liSleepTime);//循环等待时间
end;
end;
画图类部分代码
//构造函数
constructor TDrawControlChart.CreateWithParam;
begin
inherited Create(nil);
try
oPriChart := TChart.Create(Self);
oSecChart := TChart.Create(Self);
Except
//
end;
end;
//析构函数
destructor TDrawControlChart.Destroy;
begin
try
FreeAndNil(oPriChart);
FreeAndNil(oSecChart);
inherited; //经过几个小时之后,继承的基类的seriescount报错。
except
on E:Exception do
begin
messagebox(e.message)
end;
end;
end;
不知道TChart是否与Thead有冲突?
在我做的demo中,调用45个线程,运行大概2个小时后,线程就剩下3个甚至是1个。
通过调试工具跟踪发现,Tchart对象在销毁画图类的时候。
判断SeriesCount出错。
我把所有分数送出,请高手指教。
下面部分代码:
线程画图:
procedure TQueryThread.Execute;
var
loDrawChart : TDrawControlChart;
begin
{ Place thread code here }
loDrawChart:=nil;
while True do
begin
if Terminated then
exit;
try
try
//画图动作begin
loDrawChart := TDrawControlChart.CreateWithParam;
loDrawChart.DrawControlChart;
loDrawChart.AdapterConrelChartStyle(1,loPriTee,loSecTee);
synchronize(SetChartTee); //同步VCL
//画图动作end
//调用成功
except
//调用失败
end;
finally
FreeAndNil(loDrawChart);
end;
sleep(liSleepTime);//循环等待时间
end;
end;
画图类部分代码
//构造函数
constructor TDrawControlChart.CreateWithParam;
begin
inherited Create(nil);
try
oPriChart := TChart.Create(Self);
oSecChart := TChart.Create(Self);
Except
//
end;
end;
//析构函数
destructor TDrawControlChart.Destroy;
begin
try
FreeAndNil(oPriChart);
FreeAndNil(oSecChart);
inherited; //经过几个小时之后,继承的基类的seriescount报错。
except
on E:Exception do
begin
messagebox(e.message)
end;
end;
end;