Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Pascal - Sub routine
Forum - Pascal - Sub routine

Avatar
falaskhouse (Normal User)
Newbie


Messaggi: 14
Iscritto: 18/05/2010

Segnala al moderatore
Postato alle 21:28
Martedì, 09/11/2010
come faccio ad eseguire due sub routine contemporaneamente? :) grazie in anticipo...

PM
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Up
1
Down
V
Segnala al moderatore
Postato alle 22:13
Martedì, 09/11/2010
Devi usare i threads.


Il mio blog: https://piero.dev
PM
Avatar
falaskhouse (Normal User)
Newbie


Messaggi: 14
Iscritto: 18/05/2010

Up
0
Down
V
Segnala al moderatore
Postato alle 14:55
Mercoledì, 10/11/2010
non è che potresti spiegarmi come si fa :)

PM
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Up
0
Down
V
Segnala al moderatore
Postato alle 17:46
Giovedì, 11/11/2010
Un esempio lo trovi qui: http://www.pierotofy.it/pages/sorgenti/browse/18393/4145/

Per maggiore documentazione, fai un po' di ricerca su CreateThread.


Il mio blog: https://piero.dev
PM
Avatar
Saladino (Member)
Pro


Messaggi: 90
Iscritto: 30/05/2010

Up
0
Down
V
Segnala al moderatore
Postato alle 15:46
Venerdì, 12/11/2010
Questa è specifica per windows :

Codice sorgente - presumibilmente Delphi

  1. program Project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  7.   cthreads,
  8.   {$ENDIF}{$ENDIF}
  9.   Classes ,windows
  10.   { you can add units after this };
  11.  
  12. {$R *.res}
  13.  
  14. var
  15.   Ok : boolean;
  16.   ercode : longint;
  17.   Thr ,th : longword;
  18.  
  19. procedure procedura1;
  20. begin
  21. //
  22. //todo
  23. //
  24. MessageBox(0 ,'Thread in funzione' ,'' ,0);
  25. end;
  26.  
  27. function Thread(P : pointer) : longint; stdcall;
  28. begin
  29. Ok := True;
  30. procedura1;
  31. Thread := 0;
  32. end;
  33.  
  34. procedure procedura2;
  35. begin
  36. //
  37. //todo
  38. //
  39. end;
  40.  
  41. begin
  42. // ....
  43. Thr := CreateThread(nil, 0, @Thread, nil, 0, Th);
  44. repeat
  45.  getexitcodethread(Thr ,@ercode);
  46. until OK or (ercode <>still_active);
  47. //if ok<>still_active then    errore
  48. procedura2;
  49. readln;
  50. //.....
  51. end.




PM