Bonjour
Je n'arrive pas à utiliser la fonction WaitForMultipleObjects.
Dans ma fiche principale j'ai ceci :
Je créé les threads récupere le handle et attend la fin
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 for ms := 1 to 12 do begin tab_thread[ms-1]:=TThreadGraphSynthese.Create(tab_ibc_qry[ms-1],nom_stored_proc,prjt,'T'+IntToStr(t),EncodeDate(an,ms,1),IncMonth(EncodeDate(an,ms,1),1)); //recupere le handle tab_thread_hdl[ms-1]:=tab_thread[ms-1].Handle; end; //attend la fin des threads WaitForMultipleObjects(12,@tab_thread_hdl,TRUE,INFINITE);
Voici la fonction de création de mon thread
je remarque que lorsque la fonction WaitForMultipleObjects est terminée mes
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 constructor TThreadGraphSynthese.Create(ibc_qry:TIBCQuery; nom_stored_proc,prjt,trbn: string; dt_deb,dt_fin:TDateTime); begin //FreeOnTerminate:=TRUE; IbcQry:=ibc_qry; IbcQry.SQL.Text:='SELECT * FROM '+nom_stored_proc+'(:PRJT, :TRBN, :DATE_DEB, :DATE_FIN)'; IbcQry.ParamByName('PRJT').AsString:=prjt; IbcQry.ParamByName('TRBN').AsString:=trbn; IbcQry.ParamByName('DATE_DEB').AsDate:=dt_deb; IbcQry.ParamByName('DATE_FIN').AsDate:=dt_fin; ThreadTerminated:=FALSE; OnTerminate:=OnTerminateProcedure; Inherited Create(FALSE); end; procedure TThreadGraphSynthese.OnTerminateProcedure(Sender: TObject); begin ThreadTerminated:=TRUE; end; procedure TThreadGraphSynthese.Execute; begin IbcQry.Execute; end;
threads ne le sont pas car si je regarde la variable ThreadTerminated elle
est à false. Et ensuite j'ai des violations d'acces sur des variables non
initialisées.
Merci
Partager