Ignore:
Timestamp:
Jun 7, 2024, 11:59:43 AM (5 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/JobProgressView.pas

    r84 r85  
    1 unit UJobProgressView;
    2 
    3 {$MODE Delphi}
     1unit JobProgressView;
    42
    53interface
     
    75uses
    86  SysUtils, Variants, Classes, Graphics, Controls, Forms, Syncobjs,
    9   Dialogs, ComCtrls, StdCtrls, ExtCtrls, Contnrs, UThreading, Math,
     7  Dialogs, ComCtrls, StdCtrls, ExtCtrls, Generics.Collections, Threading, Math,
    108  DateUtils;
    119
     
    7169  end;
    7270
    73   TJobs = class(TObjectList)
     71  TJobs = class(TObjectList<TJob>)
    7472  end;
    7573
     
    105103    procedure ReloadJobList;
    106104    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    107     procedure FormDestroy(Sender: TObject);
    108105    procedure ListViewJobsData(Sender: TObject; Item: TListItem);
    109106    procedure TimerUpdateTimer(Sender: TObject);
     
    157154  end;
    158155
    159   //var
    160   //  FormJobProgressView: TFormJobProgressView;
    161 
    162156procedure Register;
    163157
    164158resourcestring
    165159  SExecuted = 'Executed';
     160
    166161
    167162implementation
     
    187182  try
    188183    try
    189       //raise Exception.Create('Exception in job');
    190184      ProgressView.CurrentJob.Method(Job);
    191185    except
     
    286280end;
    287281
    288 procedure TFormJobProgressView.FormDestroy(Sender:TObject);
    289 begin
    290 end;
    291 
    292282procedure TFormJobProgressView.ListViewJobsData(Sender: TObject; Item: TListItem);
    293283begin
    294284  if (Item.Index >= 0) and (Item.Index < JobProgressView.Jobs.Count) then
    295   with TJob(JobProgressView.Jobs[Item.Index]) do begin
     285  with JobProgressView.Jobs[Item.Index] do begin
    296286    Item.Caption := Title;
    297287    if Item.Index = JobProgressView.CurrentJobIndex then Item.ImageIndex := 1
     
    405395    I := 0;
    406396    while I < Jobs.Count do
    407     with TJob(Jobs[I]) do begin
     397    with Jobs[I] do begin
    408398      CurrentJobIndex := I;
    409       CurrentJob := TJob(Jobs[I]);
     399      CurrentJob := Jobs[I];
    410400      JobProgressChange(Self);
    411401      StartTime := Now;
     
    420410        Method(CurrentJob);
    421411      end else begin
     412        Thread := TJobThread.Create(True);
    422413        try
    423           Thread := TJobThread.Create(True);
    424414          with Thread do begin
    425415            FreeOnTerminate := False;
     
    494484  if AValue = FTerminate then Exit;
    495485  for I := 0 to Jobs.Count - 1 do
    496     TJob(Jobs[I]).Terminate := AValue;
     486    Jobs[I].Terminate := AValue;
    497487  FTerminate := AValue;
    498488end;
     
    620610procedure TProgress.Increment;
    621611begin
    622   try
    623     FLock.Acquire;
     612  FLock.Acquire;
     613  try
    624614    Value := Value + 1;
    625615  finally
     
    630620procedure TProgress.Reset;
    631621begin
    632   try
    633     FLock.Acquire;
     622  FLock.Acquire;
     623  try
    634624    FValue := 0;
    635625  finally
     
    647637begin
    648638  FLock.Free;
    649   inherited Destroy;
     639  inherited;
    650640end;
    651641
     
    678668destructor TJob.Destroy;
    679669begin
    680   Progress.Free;
     670  FreeAndNil(Progress);
    681671  inherited;
    682672end;
Note: See TracChangeset for help on using the changeset viewer.