⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uendlessthread.pas

📁 这是不可多得的源代码
💻 PAS
字号:
unit uEndlessThread;

interface

uses
  SysUtils, Classes;

type
  TEndless = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
    procedure UpdateMainForm;
  end;

implementation

uses fmEndless;

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TEndless.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TEndless }

procedure TEndless.UpdateMainForm;
begin
  Form1.ListBox1.Items.Add(IntToStr(Self.ThreadID) + ' : ' + FloatToStr(Random * 100000));
  if (Form1.ListBox1.Items.Count > 1000) then
    Form1.ListBox1.Items.Clear;
end;

procedure TEndless.Execute;
begin
  { Place thread code here }
  Randomize;

  while (not Self.Terminated) do
    Synchronize(UpdateMainForm);
end;

end.
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -