有两个程序都是用Indy写的,两个都用多线程,都是服务器程序,一开始那几天程序运行都是正常的,但过几天都出现CPU占25%的情况,一出现这个问题程序的就会停止在某个地方,例如一个是停在主线程的IdTCPServer1Execute,代码如下:
WriteDataLog(datetimetostr(now)+ ':开始上传文件',StrExePath);//写日志
cs.Enter;//CS: TCriticalSection;定义
WriteDataLog(datetimetostr(now)+ ':Cliet 上传文件本地保存名称1:'+ TheFileName,StrExePath);//写日志,*******查看日志时只能看到上一句日志,下面这句没了还有另外一个程序,线程Execute是这样的
procedure thDealData.Execute;
begin
WriteDataLog('['+datetimetostr(now)+']线程启动',1);//写日志
main;//一个procedure,,在此过程的最后我写的日志,说明此函数是正常的执行完的
WriteDataLog('['+datetimetostr(now)+']线程停止',1);//写日志,同样只看到上面的那句看不到这句
end;
下面的这个程序是定时去开线程的,如果我设置的时间间隔越短程序出现此问题的次数越频繁,反之则相反
问题陈述完毕了,就高手指教
WriteDataLog(datetimetostr(now)+ ':开始上传文件',StrExePath);//写日志
cs.Enter;//CS: TCriticalSection;定义
WriteDataLog(datetimetostr(now)+ ':Cliet 上传文件本地保存名称1:'+ TheFileName,StrExePath);//写日志,*******查看日志时只能看到上一句日志,下面这句没了还有另外一个程序,线程Execute是这样的
procedure thDealData.Execute;
begin
WriteDataLog('['+datetimetostr(now)+']线程启动',1);//写日志
main;//一个procedure,,在此过程的最后我写的日志,说明此函数是正常的执行完的
WriteDataLog('['+datetimetostr(now)+']线程停止',1);//写日志,同样只看到上面的那句看不到这句
end;
下面的这个程序是定时去开线程的,如果我设置的时间间隔越短程序出现此问题的次数越频繁,反之则相反
问题陈述完毕了,就高手指教
解决方案 »
- 使用IDHTTP后弹出Connection Closed Grancefully.
- 如何取得滚动条的宽度?
- 【板务醒目】辞去 Windows SDK/API 板斑竹职务 3/10【散分醒目】
- 请问关于拖动的时候的虚框的问题
- delphi中如何得到日期随机数?
- 一鼓作气,再而竭,三而衰
- 山东省烟台籍的程序员请进!
- 这样用画布在Panel上画不同的颜色,比如一个白色,一个红色,密度自己定义,谢谢!
- 再问:有关 Delphi 6 的 TValueListEditor 组件问题。
- delphi中,播放.wav文件速度最快的是什么方法?
- dbcombobox下拉风格设置为dropdownlist风格后为后无法获得数据字段的值?
- 没用过Delphi,请问用VC++ 6.0开发出来的标准的Windows DLL导出类可以在Delphi中直接使用吗?
Procedure WriteDataLog(Const LogStr : String;LogType:byte);
Var
handle : Integer;
logfile: integer;
FilePath : String;
tmp : String;
PathError:string;
begin
try
tmp := LogStr; if LogType=1 then
PathError:=GetAppPath +'\Log\Error'
else
PathError:=GetAppPath +'\Log\dealFor';
FilePath := PathError;
FilePath := FilePath + '\' + FormatDatetime('YYYY-MM-DD',now) + '.Log';
if not fileexists(FilePath) then
Begin
handle := filecreate(FilePath);
fileclose(handle);
End; logfile := fileopen(FilePath, fmOpenWrite);
fileseek(logfile, 0, 2);
filewrite(logfile, #13#10, length(#13#10));
filewrite(logfile,tmp[1],Length(Tmp));
fileclose(logfile); except
end;
end;
CS.Enter //进入了关键段
....
但没有看到关键段离开的语句
是否忘了写 CS.LeaveWriteDataLog(datetimetostr(now)+ ':开始上传文件',StrExePath);//写日志
cs.Enter;//CS: TCriticalSection;定义
WriteDataLog(datetimetostr(now)+ ':Cliet 上传文件本地保存名称1:'+ TheFileName,StrExePath);//