WaitForSingleObject(hEvent, INFINITE);
while not Terminated do
begin
GetURL;//这个过程是从库里得到网址给"Furl" 变量
html := Fhttp.Get(Furl); //执行下载网页 "Furl"
CrackLink(html, taskName, web_rank, Furl);//分析连接加入数据库
end;
目前程序运行一一段时间就停了 但库里还有网址 不知道为何停止
这个 WaitForSingleObject(hEvent, INFINITE);放的位置对不对 该如何使用
如何让这个线程一值运行 直到库里没有连接为止
解决方案 »
- 我想把一个RIDL文件转换为ACTIVEX,该怎么做?在线等待
- 文件加载到剪切板
- 哪位大哥有用panel做的房态图的DEMO呢?高分求
- 请问在DELPHI2006中能不能创建WIN32工程?
- 菜鸟问题,高手来指点一下了....
- tdbchart控件横坐标问题,急啊
- 程序运行到一半时,在任务管理器看到其显示为未响应,此时CPU占用为0.请问这都有可能是什么原因造成的.
- [提问]两个窗体之间发生的问题。具体请进去看代码及说明。 谢谢。
- 5分钟内能解决这个问题的人在深圳月工资6000以上......
- MSComm,如何判断当前端口是否正在被占用或不可用?
- 最近,老大布置了个任务。。给卡住了!
- ODAC访问ORACLE数据库问题
没看出它对本过程的影响,而时间又是一直等待,不好判断,还有你的GetUrl是不是取一条就剔除一条呢?
GetUrl 是个临界区已经cs.enter cs.leave. 它里面通过库里ID字段 当一线程访问过 我就记下当前的ID 下次再执行 就找大于这个ID的值 再记下这次读取ID值 反反复复
如果是,应该放在While 中去,结束线程注意要先销毁hEvent
在里边加入库地址总数,然后加个判断是否大于了库地址数,这样就行了
另外,enter与leave间的代码尽量减少,一是提高效率,减少不必要的互相等待;二是逻辑简单,不至于不小心出现我上面说的非正常exit。
共享列表,有个专门的类:TthreadList停、启线程:Suspend and Resume:A thread can be started and stopped any number of times before it finishes executing. To stop a thread temporarily, call its Suspend method. When it is safe for the thread to resume, call its Resume method. Suspend increases an internal counter, so you can nest calls to Suspend and Resume. The thread does not resume execution until all suspensions have been matched by a call to Resume.You can request that a thread end execution prematurely by calling the Terminate method. Terminate sets the thread's Terminated property to True. If you have implemented the Execute method properly, it checks the Terminated property periodically, and stops execution when Terminated is True.