在线程中如何通知主线程一些信息啊?(40)

X

xf_z

Unregistered / Unconfirmed
GUEST, unregistred user!
在线程中如何通知主线程一些信息啊?比如成功执行完了,或者出错了,是哪错了之类的
 
使用事件
 
PostMessage
 
能否给个例子啊
 
难到不会google,baidu?http://99inf.net/SoftwareDev/Delphi/35321.htmhttp://hi.baidu.com/wangzheng81/blog/item/c6002f0ebca408c97bcbe11a.htmlhttp://dev.21tx.com/2005/02/27/11330.html
 
搭车问一下,如果程序中没有窗口怎么办?
 
没窗口, 可以传入回调函数。或者 传一事件过程(通过事件过程属性)
 
TNotifyProc = procedure (要传的参数) of object;TMyThread = class(TThread)private FNotifyEvent:TNotifyProc;protected procedure Execute;
override;public property NotifyEvent: TNotifyProc write FNotifyEvent;
end;
// 实现procedure TMyThread.Execute;
begin
if FNotifyEvent <> nil then
FNotifyEvent(要传的参数);
end;
 
发消息吧.
 
谢谢 liuls。
 
1.发消息2.使用回调函数
 
顶部