Autor Beitrag
stOrM!
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Fr 16.06.06 09:32 
Hallo,
ich brauch mal Hilfe bezüglich einer ads datenbank, die mittels thread komprimiert werden soll (re-index)

das problem was ich grad hab ist glaub ich der implementierte callback für die progressbar oder aber ne update frage...

der thread an sich läuft wie gewünscht nur leider wird bei einer größeren tabelle, die progressbar erst dann wieder upgedatet, wenn die eigentlich komprimierung beendet ist aber nicht wärenddessen...
muss man sich so vorstellen: start thread, progressbar bei position = 0 thread ende progressbar = 100 komprimierung abgeschlossen ist, leider nicht während dessen, so das der user sieht das auch wirklich was passiert und das programm nicht etwas abgeschmiert ist (sinn oder unsinn einer progressbar ) :oops:

hier mal ein wenig code, vielleicht sieht jemand das problem?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
unit PckThrd;

interface

uses
  Windows,
  Classes,
  AdsTable,
  AdsSet,
  AdsData,
  SysUtils,
  ACE,
  Forms,
  dbTables,
  dialogs;

type
  TPckThrd = class(TThread)
  private
    { Private declarations }
    FstrTableName: string;
  protected
    procedure Execute; override;
  public
    constructor Create( strTableName: string );
  end;

function SendProgress( Percent: Word ): LongInt; stdcall;

implementation

uses
   unit1, unit2;

function SendProgress( Percent: Word ): Longint; stdcall;
begin
   Result := 0;

   SendMessage( Form2.Handle,
                PROGRESS_MESSAGE,
                Percent,
                0 );

   Application.ProcessMessages();
end;

Constructor TPckThrd.Create( strTableName: string );
begin
   inherited Create( true ); //Create the thread suspended.
   OnTerminate := Form2.FinishedIndexing;
   FstrTableName := strTableName;
   FreeOnTerminate := true;
   Resume; 
end;

procedure TPckThrd.Execute;
Var
  AdsTable2: TAdsTable;

begin
if Terminated then
      exit;

      AdsTable2 := TAdsTable.Create( nil );
      AdsTable2.AdsRegisterProgressCallback(@SendProgress);

 with AdsTable2 do
   begin
     try
      Form1.AdsConnection1.AdsServerTypes := [stAds_Local];
      Form1.AdsConnection1.ConnectPath := ExtractFileDir( FstrTableName );
      Form1.AdsConnection1.Connect;
      AdsTable2.AdsConnection := Form1.AdsConnection1;
      AdsTable2.DatabaseName :=  'Form1.AdsConnection1';
      AdsTable2.TableName := ExtractFileName( FstrTablename );
      AdsTable2.Exclusive := true;
      AdsTable2.Open;
      AdsTable2.AdsPackTable;
    finally
      AdsTable2.Free();
      Form1.AdsConnection1.Connect;
      Form1.AdsTable1.Open;
      Form2.Close;
        end;
      end;
    end;
end.


danke!
s!

Moderiert von user profile iconjasocul: Delphi-Tags hinzugefügt
Moderiert von user profile iconjasocul: Topic aus Datenbanken verschoben am Fr 16.06.2006 um 10:45
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Fr 16.06.06 12:01 
Aber du rufst dein SendProgress doch auch nirgendswo auf :(
stOrM! Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Fr 16.06.06 14:04 
user profile icondigi_c hat folgendes geschrieben:
Aber du rufst dein SendProgress doch auch nirgendswo auf :(


Hi,
ich denke schon und zwar hier:
ausblenden Delphi-Quelltext
1:
AdsTable2.AdsRegisterProgressCallback(@SendProgress);					


Soweit ich die ADS Doku verstanden habe, sobald ich ein z.B. Query aufrufe oder wie oben die Pack Routine muss vorher der Aufruf AdsRegisterProgressCallback aufgerufen werden.
Die Aktualisierung übernimmt die Engine selber...