哪可不一定!如下面的代码:结果是Edit1从1到30000没有问题,但Edit2没有一次从1到30000的.都是Application.ProcessMessages的原因.Timer1,Timer2的时间设为5秒!(我试了一下,就算是一个新的程序,什么都没有动过,运行起来也有2个线程,不知为什么?)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
i:integer;
begin
for i:=1 to 30000do
begin
Application.ProcessMessages;
edit1.Text:=inttostr(i);
end;
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var
i:integer;
begin
for i:=1 to 30000do
begin
Application.ProcessMessages;
edit2.Text:=inttostr(i);
end;
end;
end.