线程的调用与其它问题,请高手解解. |
尚未結案
|
eoisoft
一般會員 發表:20 回覆:12 積分:6 註冊:2004-11-24 發送簡訊給我 |
线程PAS如下;
unit clickThds; interface uses Classes,IdHTTP,StdCtrls,Autoclick, SysUtils; type TUrlsClick = class(TThread) private { Private declarations } fi:integer; fOleName:TListBox; fHttpOld:TIDHTTP; protected procedure Execute; override; //procedure goUrls(var i:integer;var OleName:TListBox;var HttpOld:TIDHTTP); virtual; abstract; public constructor Create(var i:integer;var OleName:TListBox;var HttpOld:TIDHTTP); procedure goUrls(var i:integer;var OleName:TListBox;var HttpOld:TIDHTTP); virtual; abstract; end; implementation constructor TUrlsClick.Create(var i:integer;var OleName:TListBox;var HttpOld:TIDHTTP); begin inherited Create(False); fi:=i; fOleName:=OleName; fHttpOld:=HttpOld; end; procedure TUrlsClick.Execute; begin FreeOnTerminate := True; goUrls(fi,fOleName,fHttpOld); end; procedure goUrls(var i:integer;var OleName:TListBox;var HttpOld:TIDHTTP); var fs:tstringlist; url:string; begin fs:=TstringList.Create(); fs.Add(''); while i<=OleName.Items.Count - 1 do begin //StatusBar1.Panels[2].Text:=inttostr(i 1) '/' inttostr(ListBox1.Items.Count-1); Url:=OleName.Items.Strings[i]; try HttpOld.post(Url,fs); except HttpOld.Disconnect; end; mainForm.StringGrid1.Cells[2,i 1]:=Inttostr(strtoint(mainForm.StringGrid1.Cells[2,i 2]) 1); i:=i 1; if mainForm.checkbox1.Checked and (i>OleName.Items.Count - 1) then i:=0; mainForm.Edit1.Text:=IntToStr(StrtoInt(mainForm.Edit1.Text) 1); end; end; end.在主PAS中我是这样调用的,我知道不对,能否讲解一下: ......... Count_jc:=10; setLength(IDDL,Count_jc); setLength(TThe,Count_jc); for i:=0 to strtoint(ComboCs.Text) do begin IDDL[i]:=TIDHTTP.Create(self); IDDL[i].ReadTimeout:=10000; IDDL[i].OnWorkBegin:=httpWorkBegin; IDDL[i].OnWork:=httpWork; IDDL[i].OnWorkEnd:=WorkEnd; IDDL[i].HandleRedirects:=true; end; ........ //这里我想自动创建与IDDL数组相关联的线程(要如何去做呀?) for ii:=0 to Count_jc do begin Tgo.Create(i,mainform.ListBox1,IDDL[ii]); end; 请各位大大,说说我这样做可以吗?我是初学者,不要说我笨喔,要学习才有进步吗? |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |