mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 04:37:35 +01:00
Opkman: Call Synchronize from the currently active thread. Increase sleep interval to prevent CPU load.
git-svn-id: trunk@57263 -
This commit is contained in:
parent
fc6109b79c
commit
af3a94500f
@ -282,7 +282,8 @@ begin
|
||||
FErrMsg := rsMainFrm_rsMessageError2;
|
||||
FErrTyp := etTimeOut;
|
||||
FTimer.StopTimer;
|
||||
Synchronize(@DoOnJSONDownloadCompleted);
|
||||
TThreadTimer(Sender).Synchronize(@DoOnJSONDownloadCompleted);
|
||||
//Synchronize(@DoOnJSONDownloadCompleted);
|
||||
FOnJSONComplete := nil;
|
||||
end
|
||||
else if (FDownloadType = dtPackage) or (FDownloadType = dtUpdate) then
|
||||
|
||||
@ -29,7 +29,7 @@ unit opkman_intf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Dialogs, Controls, contnrs, fpjson, ExtCtrls,
|
||||
Classes, SysUtils, Forms, Dialogs, Controls, contnrs, fpjson,
|
||||
// IdeIntf
|
||||
LazIDEIntf, PackageIntf, PackageLinkIntf, PackageDependencyIntf, IDECommands,
|
||||
// OPM
|
||||
@ -45,7 +45,7 @@ type
|
||||
FPackagesToInstall: TObjectList;
|
||||
FPackageDependecies: TObjectList;
|
||||
FPackageLinks: TObjectList;
|
||||
FWaitForIDE: TTimer;
|
||||
FWaitForIDE: TThreadTimer;
|
||||
FNeedToInit: Boolean;
|
||||
FBusyUpdating: Boolean;
|
||||
procedure DoWaitForIDE(Sender: TObject);
|
||||
@ -83,15 +83,17 @@ begin
|
||||
FPackagesToInstall := TObjectList.Create(False);
|
||||
FPackageDependecies := TObjectList.Create(False);
|
||||
FNeedToInit := True;
|
||||
FWaitForIDE := TTimer.Create(nil);
|
||||
FWaitForIDE := TThreadTimer.Create;
|
||||
FWaitForIDE.Interval := 100;
|
||||
FWaitForIDE.OnTimer := @DoWaitForIDE;
|
||||
FWaitForIDE.StartTimer;
|
||||
end;
|
||||
|
||||
destructor TOPMInterfaceEx.Destroy;
|
||||
begin
|
||||
FWaitForIDE.OnTimer := nil;
|
||||
FWaitForIDE.Free;
|
||||
FWaitForIDE.StopTimer;
|
||||
FWaitForIDE.Terminate;
|
||||
FWaitForIDE.WaitFor;
|
||||
FPackageLinks.Clear;
|
||||
FPackageLinks.Free;
|
||||
FPackagesToDownload.Clear;
|
||||
@ -115,9 +117,9 @@ begin
|
||||
begin
|
||||
InitOPM;
|
||||
FNeedToInit := False;
|
||||
FWaitForIDE.Enabled := False;
|
||||
FWaitForIDE.Interval := 10000;
|
||||
FWaitForIDE.Enabled := True;
|
||||
FWaitForIDE.StopTimer;
|
||||
FWaitForIDE.Interval := 5000;
|
||||
FWaitForIDE.StartTimer;
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
||||
@ -79,7 +79,7 @@ procedure TThreadTimer.Execute;
|
||||
begin
|
||||
while not Terminated do
|
||||
begin
|
||||
Sleep(1);
|
||||
Sleep(100);
|
||||
if (GetTickCount64 - FTime > FInterval) and (FEnabled) then
|
||||
begin
|
||||
FTime := GetTickCount64;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user