Autor Beitrag
Xenar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: Mi 20.04.05 18:55 
Hallo ich habe in meinem Form1 ein thread erzeugt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
  var
  ThreadID: DWORD;
  ThreadHandle: THandle;
  begin
    ThreadHandle:=CreateThread(nil, 0, TFNThreadStartRoutine(@StartThread),
    nil, 0, ThreadID);
    if ThreadHandle<>0 then CloseHandle(ThreadHandle);

in diesem will ich jetzt eine prozedur aus form1 starten
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure StartThread;
begin
  //procedure irgendwas in form1 starten
end;

wie mache ich das mit prozedure irgendwas(self); geht es nicht

:cry:
ciao Xenar

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 20.04.05 18:59 
Als erstes müsstest Du auf jeden Fall ein "Sync" machen. Wie das mit purer API gleich geht, weiß ich net ausm Kopf, jedenfalls gibt es ansonsten Probleme ...

BTW: Warum dann nicht in der Sync-Proc Form1.Methode(Params)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 20.04.05 19:02 
user profile iconXenar hat folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
procedure StartThread;
begin
  //procedure irgendwas in form1 starten
end;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
uses Unit1; // Die Unit in dem das Formular ist
...

procedure StartThread;
begin
  Form1.MyMethod;
end;

Ich hoffe mal, dass TForm1.MyMethod nichts mit der VCL macht, genauer genommen, nichts macht, was eine Synchronisierung mit dem Haupt-Thread nötig macht.

_________________
Ist Zeit wirklich Geld?
Xenar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45



BeitragVerfasst: Mi 20.04.05 19:21 
Hallo liebe helfer,

ich erzeuge den Thread wiegesag in Unit1 mit folgenden code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.StartClick(Sender: TObject);
  var
  ThreadID: DWORD;
  ThreadHandle: THandle;
  begin
    ThreadHandle:= CreateThread(nil, 0, TFNThreadStartRoutine(@StartAuto),
    nil, 0, ThreadID);
    if ThreadHandle<>0 then CloseHandle(ThreadHandle);
  end;


wo soll ich da das uses einfügen? Bin noch blutiger anfänger... :roll:

Zum Synchronisieren, ich kopiere mit dem thread aus unit1 etwas aus einer tabelle in editfelder, auch in unit1. brauche ich da eine synchronisierung?

Moderiert von user profile iconMotzi: Code- durch Delphi-Tags ersetzt.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 20.04.05 20:59 
user profile iconXenar hat folgendes geschrieben:
Bin noch blutiger anfänger

Dann solltest du vorerst mal die Finger von Threads, insbesondere von der direkten Verwendung der Win32API Threads, lassen.
Wenn du wissen willst, wie das mit Threads geht dann solltest du dir mal das "Threads"-Beispiel im Demo-Ordner von Delphi anschauen.

_________________
Ist Zeit wirklich Geld?
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 20.04.05 21:57 
Und man sollte nicht CreateThread direkt verwenden, sondern den Wrapper, den die Klassen-Bibliothek bereitstellt. Bzw. in Delphi wäre das BeginThread aus der Unit Windows.pas. Alles weitere in meinem Tutorial: tutorials.luckie-online.de