Показать сообщение отдельно
  #1  
Старый 24.05.2011, 15:32
Аватар для SpectraL
SpectraL SpectraL вне форума
Начинающий
 
Регистрация: 19.05.2011
Адрес: Санкт-Петербург
Сообщения: 112
Версия Delphi: 10.1 Berlin
Репутация: 10
По умолчанию Thread Object и объявление главного модуля приложения

Это пример из книги "Библия 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.
Ответить с цитированием