急!!!!!关闭多线程程序的问题(分数不够在加!)(200分)

Z

zjgo

Unregistered / Unconfirmed
GUEST, unregistred user!
关闭多线程程序时,偶尔会出现蓝屏和windows错误,错误提示如下:
windows
an error has occurred,to continue:
press enter to return to windows,or
press CTRL+ALT+Del to restart your computer.
if youdo
this,you will lose any unsaved information in all
open applications .
File name: VWIN32(05)+000012D0 Error:0E:0028:C02A4530
press any key to continue
采取什么机制才能解决以上问题?
分数不成问题,不够在给!!
在线等待!
 
我的释放线程的程序如下:
function FreeAll: boolean;
var i: integer;
begin
for i:=Channel_min to Channel_Maxdo
begin
Channel.ThreadCmd.Resume;
while Channel.ThreadCmdStatus<>0do
{0是在用}
begin
Channel.ThreadCmd.Resume;
{ 激活指令线程 }
Channel.ThreadCmd.Terminate;
Channel.EventCmd.SetEvent;
{ 通知指令线程 }
{EventCmd说明:Channel.EventCmd:=TEvent.Create(Nil,false,false,'EventCmd'+inttostr(i));}
{主要用他来使用waitfor()}
end;
end;
end;
 
Channel.ThreadCmd.Resume;
{ 激活指令线程 }
Channel.ThreadCmd.Terminate;//线程已经终止了
Channel.EventCmd.SetEvent;
//为什么还要setevent?
 
To resun:
我的线程中是这么写的:
while not Terminateddo
begin
.....
end;
要不要setevent呢?
 
to resun:
我的程序是偶尔出现蓝屏的。没有确定性。
即使是我的线程什么也不做,也会有这种问题,
怎么解决呢?
 
我也写过类似的程序,是这样写的
While not Terminateddo
begin
WaitForSingleobject(hmutex,infinite);
.......
然后用了一个timer
setEvent(hMutex)
 
有可能是操作系统的问题,你换台win2000机器试试
 
To resun:
WaitForSingleobject(hmutex,infinite);中
hmutex这个句柄要另外定义吗?
我的waitfor 要根据不同情况设定等待时间,
你的infinite怎么设定不同时间?
 
hMutex:=CreateEvent(nil,false,false,nil);
我只是说明我的用法而已,跟你的程序无关,只是要你看一下用法
 
to resun :
我怀疑是线程没有完全释放的时候,主程序就终止了,才会出现蓝屏。
用什么方法判断线程已经完全释放?
 
因为看不到你的程序的全部,所以也不太清楚到底是什么原因。你用的是win98吧?win98本来
就有很多问题,即使你的程序没有问题,有时候也会出现这样的问题
用Terminated 应该可以判断
 
或者你在主程序终止前,用Channel.ThreadCmd.Terminate终止所有的线程试试
 
Channel.EventCmd在主程序终止时也应该释放
 
to resun:
你上面说的,我都做了,不过还是要谢谢
你的提醒:)
 
to resun:
terminated在线程外部怎么使用?
if Channel.ThreadCmd.terminated then
上一句是不可以使用的啊?
说terminated没有定义。
 
to resun :
测出:是windows系统的问题,和程序无关,谢谢,200分加给你了~:)
 
接受答案了.
 
顶部