码迷,mamicode.com
首页 > 编程语言 > 详细

delphi 主线程向子线程发送消息

时间:2017-03-09 20:49:04      阅读:646      评论:0      收藏:0      [点我收藏+]

标签:while   continue   处理   input   failed   事件   phi   cts   消息队列   

while True do
begin
if not PeekMessage(msg,0,0,0,PM_REMOVE) then
begin
case MsgWaitForMultipleObjects(1,hCloseEvent,False,INFINITE,QS_ALLINPUT) of
WAIT_OBJECT_0: Break;//hCloseEvent事件已经有效,故结束
WAIT_OBJECT_0+1:Continue;//消息队列中有消息存在
else Break;//其它情况,WM_FAILED或WAIT_ABANDONED_0,表明已经出错,故结束
end;
end else
begin
if WaitForSingleObject(hCloseEvent,0)<>WAIT_TIMEOUT then Break;
case msg.message of
WM_TEST:
begin
//...接到主线程发过来的命令,作相应处理
//...处理完之后,也可以用消息通知主线程
end;
end;
end;
end;
finally
//...作善后处理
end;

delphi 主线程向子线程发送消息

标签:while   continue   处理   input   failed   事件   phi   cts   消息队列   

原文地址:http://www.cnblogs.com/zhangzhifeng/p/6527376.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!