Это пример из книги "Библия Delphi" -> глава 17 Потоки.
Объясните пожалуйста, почему, в дополнительном потоке (Thread Object), главный модуль приложения (Main, с главной формой) нельзя объявить в разделе interface?
Цитата:
unit MyThread;
interface
uses
Classes, SysUtils;
type
TCountObj = class(TThread)
private
index: integer;
procedure UpdateLabel;
protected
procedure Execute; override;
end;
implementation
uses Main;
procedure TCountObj.Execute;
begin
index:=1;
//Запускаем бесконечный счетчик
while index > 0 do
begin
Synchronize(UpdateLabel);
Inc(index);
if index > 100000 then index:=0;
//Если поток остановлен, то выйти,
if terminated then exit;
end;
end;
procedure TCountObj.UpdateLabel;
begin
Form3.Label1.Caption:=IntToStr(Index);
end;
end.
|