Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   BeginThread - Methoden aufruf (https://www.delphipraxis.net/154125-beginthread-methoden-aufruf.html)

youuu 30. Aug 2010 12:55

AW: BeginThread - Methoden aufruf
 
Ich hab emir mal hierangeschaut.

Als Test, habe ich ein Beispiel von der Homepage genommen

Delphi-Quellcode:
procedure TForm1.MainProc;
 
  procedure DoSomething;
 
    procedure UpdateProgressBar(Percentage: Integer);
    begin
      ProgressBar.Position := Percentage;
      Sleep(20); // This delay does not affect the time for the 0..100 loop
                 // because UpdateProgressBar is non-blocking.
    end;
 
    procedure Finished;
    begin
      ShowMessage('Finished');
    end;
 
  var
    I: Integer;
  begin
    for I := 0 to 100 do
    begin
      // Do some time consuming stuff
      Sleep(30);
      LocalAsyncVclCall(@UpdateProgressBar, I); // non-blocking
    end;
    LocalVclCall(@Finished); // blocking
  end;
 
var
  a: IAsyncCall;
begin
  a := LocalAsyncCall(@DoSomething);
  a.ForceDifferentThread; // Do not execute in the main thread because this will
                          // change LocalAyncVclCall into a blocking LocalVclCall
  // do something
  //a.Sync; The Compiler will call this for us in the Interface._Release method
end;
Zwar durch läuft alles korrekt, aber dennoch ist das Formular geblockt, was es ja normaleweise nicht sein sollte.


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:02 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz