线程和ttask delphi fmx?

我正在尝试在第二个线程上进行一些处理,为此,我目前正在使用TTask并使用从先前在此处以及在其他教程中解释的问题中获得的知识编写代码:

procedure Process;
var
  Task: ITask;
  sMS,pMS,pMS2: TMemoryStream;
  Bitmap1,Bitmap2,Bitmap3: TBitmap;
  sRect: TRect;
begin
  Form2.AniIndicator1.Visible := true;
  Task := TTask.Create(
    procedure
    begin
      sPdf := TDebenuPDFlibrary1613.Create;
      sPdf.UnlockKey('stackoverflow@1234');
      if sPdf.LoadFromFile(FileName,'RAMBO@45454593') = 1 then
      begin
        sPdf.SetOrigin(1);
        sPdf.SelectRenderer(4);
        sPdf.SetPDFiumFileName('eLibUM32.dll');
        pMS := TMemoryStream.Create;
        pMS2 := TMemoryStream.Create;
        try
          sPdf.SetPageBox(2,37,659,243,152);
          sPdf.RenderPageToStream(300,5,pMS);
          Bitmap1 := TBitmap.CreateFromStream(pMS);
          sPdf.SetPageBox(2,314,pMS2);
          Bitmap2 := TBitmap.CreateFromStream(pMS2);
          with sRect do
          begin
            Top := 0;
            Left := 0;
            Width := Bitmap1.Width;
            Height := Bitmap1.Height;
          end;
          Bitmap3:= TBitmap.Create;
          with Bitmap3 do
          begin
            Height := Bitmap1.Height;
            Width := Bitmap1.Width * 2 + 5;
            Clear(TAlphaColors.White);
            CopyFromBitmap(Bitmap1,sRect,0);
            CopyFromBitmap(Bitmap2,sRect.Width + 5,0);
          end;
          TThread.Queue(TTHread.CurrentThread,procedure
          begin
          Form2.AniIndicator1.Visible := False;
          Form2.Image1.Bitmap.Assign(Bitmap3);
          end);
        finally
          pMS.Free;
          pMS2.Free;
        end;
      end else
       TThread.Queue(TThread.CurrentThread,procedure
       begin
       ShowMessage('Password Error !');
       end);
      sPdf.Free;
    end);
  Task.Start;
end; 

,但是有时它不会将位图加载到form2的image1中。 我在任务或线程队列中有任何错误吗?

chaoduncan 回答:线程和ttask delphi fmx?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3108498.html

大家都在问