Обнаружил очередной пробел в знаниях. Таймер, созданный в подключаемой библиотеке, не работает. Как заставить его работать?
Все пишется пока в MSE под Linux
Итак имеется библиотека (оставлены строки, относящиеся к вопросу):
- Код: Выделить всё
library somelib;
type
ttyp = class(tmsecomponent)
private
ttimer1 : ttimer;
procedure on_timer(const sender: tobject);
public
constructor create;
end; //class
var sp : ttyp;
constructor ttyp.create;
begin
ttimer1 := ttimer.create(application);
ttimer1.ontimer := @on_timer;
ttimer1.interval := 100;
ttimer1.enabled := true;
inherited;
end;
procedure ttyp.on_timer(const sender: tobject);
begin
writeln('timer work!'); // <-- затык здесь, на консоль ничего не пишется, т.е таймер не работает.
end;
procedure initlib(const app : tguiapplication);
begin
sp := ttyp.create;
with sp do
begin
if ttimer1.enabled
then writeln('timer active') // <--- на консоль идет эта строка, т.е таймер создан и активен
else writeln('timer not active');
end;
end;
exports
initlib;
begin
end.
ну и подключение :
- Код: Выделить всё
program someprog;
procedure initlib(const app : tguiapplication); external 'libsomelib.so';
begin
initlib(application);
application.run;
end.
//текст исправлен с учетом замечания grot