你可以把第二个事件放在一个线程中。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TWaitThread=class(TThread)
protected
procedure Execute; override;
procedure MyAction;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TWaitThread.MyAction;
begin
showmessage('here'); //处理第二个事件
end;
procedure TWaitThread.Execute;
var MyEvent :Thandle;
begin
MyEvent := CreateEvent(nil,True,False,nil) ;
waitforSingleObject(MyEvent,120000);
CloseHandle(MyEvent);
Synchronize(MyAction);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
wt: TWaitThread;
begin
wt:=TWaitThread.Create(false);
end;
end.