Hello,
currently trying to make first steps to create my own Miletus component for controlling the Raspberry GPIO interface. I derived it from TComponent and I thought its a good idea to use a timer for polling the GPIO. Inside the timer event I'm using the GPIORead(AGPIOPin: Integer): TJSPromise; defined in WEBLib.MiletusRaspi.pas. I marked the timer event procedure with [async] and it compiled fine. When using my control in a Miletus test app, the compiler is complaining that using Await is only allowed in async procedures. What is my mistake here?
Best regards
TMiletusRaspberryGPIO = class(TComponent)
private
FPollingTimer : TTimer;
[async]procedure OnTimer(Sender : TObject);
public
constructor Create(AOwner: TComponent); override;
end;
constructor TMiletusRaspberryGPIO.Create(AOwner: TComponent);
begin
inherited;
FPollingTimer:= TTimer.Create(nil);
FPollingTimer.OnTimer:= OnTimer;
end;
[async]
procedure TMiletusRaspberryGPIO.OnTimer(Sender : TObject);
var
value : Integer;
begin
value:= Await(Integer, GPIORead(item.Port));
end;
VSC/Win10/TMSWEBCoreVSC 1.9.85543