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

📄 unit2.pas

📁 Linux 下 C 语言编程
💻 PAS
字号:
unit Unit2;

interface

uses
  Classes;

type
  TPbThread = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
    procedure StepProgress;
  public
    PbID:1..2;//注意,放在public域的目的是为了在单元以外可以放问。
  end;

implementation
uses Unit1;//注意引用unit1的位置,这是为了防止单元的循环引用
{ TPbThread }

procedure TPbThread.Execute;
var
 i : cardinal;
begin
  i := 1;
  while (i < 100000) do
  begin
  //使用synchronize是因为本线程stepProgress使用了其他线程的控件(pb1,pb2)属性.
      Synchronize(StepProgress);
      Inc(i);
  end;
end;

procedure TPbThread.StepProgress;
begin
  //根据标识pbid判断线程应该是控制哪个进度条
  if PbID=1 then Form1.Pb1.StepIt
  else Form1.Pb2.StepIt;
end;

end.

⌨️ 快捷键说明

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