async with override

I can't get async to work with override. I've put together a simple class that calls the browser SHA API with the definitions:

  TBaseSHA256 = class
  public
    function ComputeSHA256(const s: string): string; virtual; abstract;
  end;

  TSHA256 = class(TBaseSHA256)
  private
    private
    function Hex(ABuffer: TJSArrayBuffer): string;
  public
    //[async]
    function ComputeSHA256(const s: string): string; async; override; {async;}
  end;

I've tried all combinations of [async]/async; but the compiler gives me "[Error] UnitMain.pas(23): procedure type modifier "async" mismatch".

Thanks, Bob

Never mind - I forgot to add async to the original declaration!

Thanks, Bob

Hi,

You need to make sure your abstract function is marked as async too.

  TBaseSHA256 = class
  public
    [async]
    function ComputeSHA256(const s: string): string; virtual; abstract;
  end;
  
  TSHA256 = class(TBaseSHA256)
  private
    private
    function Hex(ABuffer: TJSArrayBuffer): string;  
  public
    [async]
    function ComputeSHA256(const s: string): string; override;
  end;

or

  TBaseSHA256 = class
  public
    function ComputeSHA256(const s: string): string; async; virtual; abstract;
  end;

  TSHA256 = class(TBaseSHA256)
  private
    private
    function Hex(ABuffer: TJSArrayBuffer): string;
  public
    function ComputeSHA256(const s: string): string; async; override; 
  end;

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.