procedure TForm1.Button4Click(Sender: TObject);
begin
COM_RUN:= TEvent.Create(nil,true,false,'');
COM_RUN.SetEvent;
BR:=Thread_BR.Create(false); //在这里建立起线程
WR:=Thread_BW.Create(false);
WW:=Thread_WW.Create(false);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
inc(diaoyong_BR); //随着按键的次数增加,在线程
end; //的循环里刷新memo控件的显示procedure Thread_BR.Execute; //执行线程
begin
while(RUN_COUNT_BR<diaoyong_BR) do begin
inc(RUN_COUNT_BR);
while(form1.COM_RUN.WaitFor(100)<>wrSignaled) do
begin
end;
if (Terminated) then exit;
Form1.COM_RUN.ResetEvent;
form1.Memo1.Lines.Append('BR正在进行第 '+inttostr(RUN_COUNT_BR) +' 次');
form1.delay(1000);
form1.Memo1.Lines.Append('BR结束');
Form1.COM_RUN.SetEvent();
end;
end; 问题来了,为什么先按下button4,然后我按下button1之后, memo1没有能够显示 'BR正在进行第1次'的信息.而是在先按了button1之后再按button4才显示,这是什么道理?
begin
COM_RUN:= TEvent.Create(nil,true,false,'');
COM_RUN.SetEvent;
BR:=Thread_BR.Create(false); //在这里建立起线程
WR:=Thread_BW.Create(false);
WW:=Thread_WW.Create(false);
end;procedure TForm1.Button1Click(Sender: TObject);
begin
inc(diaoyong_BR); //随着按键的次数增加,在线程
end; //的循环里刷新memo控件的显示procedure Thread_BR.Execute; //执行线程
begin
while(RUN_COUNT_BR<diaoyong_BR) do begin
inc(RUN_COUNT_BR);
while(form1.COM_RUN.WaitFor(100)<>wrSignaled) do
begin
end;
if (Terminated) then exit;
Form1.COM_RUN.ResetEvent;
form1.Memo1.Lines.Append('BR正在进行第 '+inttostr(RUN_COUNT_BR) +' 次');
form1.delay(1000);
form1.Memo1.Lines.Append('BR结束');
Form1.COM_RUN.SetEvent();
end;
end; 问题来了,为什么先按下button4,然后我按下button1之后, memo1没有能够显示 'BR正在进行第1次'的信息.而是在先按了button1之后再按button4才显示,这是什么道理?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货