Autor Beitrag
TimKellner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Mo 21.05.07 16:46 
Hallo,

ich hae ein kleines Programm geschrieben indem im Hintergund eine Datei gezippt werden.

Ich möchte das ganze in einem Zusätzlichen Thread ausführen. Doch ich bekomme immer folgende Fehlermeldung.

[Fehler] Unit_Main.pas(325): Variable erforderlich


Thread erstellen
ausblenden Delphi-Quelltext
1:
ThreadHandle:=CreateThread(nil, 0, TFNThreadStartRoutine(@Compress), nil, 0, ThreadID);					
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.05.07 17:23 
Moin!

user profile iconTimKellner hat folgendes geschrieben:
Ich möchte das ganze in einem Zusätzlichen Thread ausführen. Doch ich bekomme immer folgende Fehlermeldung.

[Fehler] Unit_Main.pas(325): Variable erforderlich

Thread erstellen
ausblenden Delphi-Quelltext
1:
ThreadHandle:=CreateThread(nil, 0, TFNThreadStartRoutine(@Compress), nil, 0, ThreadID);					

Windows.pas hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
function CreateThread(lpThreadAttributes: Pointer;
  dwStackSize: DWORD; lpStartAddress: TFNThreadStartRoutine;
  lpParameter: Pointer; dwCreationFlags: DWORD; var lpThreadId: DWORD): THandle; stdcall;

Wie ist die Deklaration von ThreadHandle, Compress und ThreadID?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
TimKellner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Mo 21.05.07 17:40 
Hi,

die Deklarationen lauten wie folgt

ThreadID: DWORD;
ThreadHandle: THandle;
function Compress(zahl: Pointer): LongInt; stdcall;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.05.07 17:43 
Moin!

Welcher Parameter genau ist denn das Problem (wo steht der Cursor)? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
TimKellner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Mo 21.05.07 17:44 
Der Curser steht hinter TFNThreadStartRoutine(@Compress)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.05.07 17:49 
Moin!

user profile iconTimKellner hat folgendes geschrieben:
function Compress(zahl: Pointer): LongInt; stdcall;

Haste dir schonmal die Typ-Deklaration von TFNThreadStartRoutine angesehen? Meine, die Funktion darf keine Parameter haben... :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
TimKellner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Mo 21.05.07 17:51 
Wie kann ich das denn sonst mit so einem Thread machen ich verstehe die Tuts leider nicht. ^^
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.05.07 17:53 
Moin!

Wenn du mit der WIN-API nicht klar kommst, warum leitest du dann nicht TThread ab? :?

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
TimKellner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Mo 21.05.07 17:55 
Das ist jetzt das erste mal das ich überhaupt mit Threads arbeite.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 21.05.07 17:57 
Moin!

Schau mal hier, da geht´s zwar um ganz was anderes, aber ich benutze dort auch TThread-Nachfahren. Vielleicht ist das Beispiel ja schon "verständlicher"... ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
TimKellner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Mo 21.05.07 18:13 
Hi,

ich habe es jetzt mit dem TThread versucht. Ein zweiter Thread wird erzeugt. Doch wenn ich nun im Thread.Execute den Befehl Sleep(5000) eingebe ist das Hauptprogramm für 5 Sek lahmgelegt aber es soll ja weiterlaufen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TMyOwnThread = class(TThread)
  protected
    procedure Execute; override;
  end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TMyOwnThread.Execute;
begin
  Sleep(5000);
end;



ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm_Main.Button_SicherungClick(Sender: TObject);
var
Thread: TMyOwnThread;
begin
Thread := TMyOwnThread.Create(True);
Thread.Execute;
end;
cuejo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: Mo 21.05.07 19:00 
Ruf mal statt Execute die Resume-Funktion auf.

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.