Advertisement
Guest User

thread

a guest
Nov 7th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.85 KB | None | 0 0
  1. Thread--------------------------------
  2.  
  3. unit Unit2;
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes , IdHTTP;
  9.  
  10. type
  11.   TPrimeThrd = class(TThread)
  12.   private
  13.   idHTTP1: TidHTTP;
  14.   FResultString: string;
  15.   protected
  16.   procedure UpdateResults;
  17.   procedure Execute; override;
  18.   public
  19.    filename:string;
  20.   end;
  21.  
  22. implementation
  23.  
  24. uses SysUtils, Dialogs, unit1;
  25.  
  26. procedure TPrimeThrd.UpdateResults;
  27. begin
  28. Form1.Memo1.Lines.Add(FResultString)
  29. end;
  30.  
  31. procedure TPrimeThrd.Execute;
  32. begin
  33. idhttp1:=TIdHTTP.Create(nil);
  34. FResultString:=idhttp1.Get(filename);
  35. Synchronize(UpdateResults);
  36. end;
  37.  
  38. end.
  39. ----------------main form----
  40. procedure TForm1.Button5Click(Sender: TObject);
  41. var
  42. newthread1,newthread2:TPrimeThrd;
  43. begin
  44. newthread1:=TPrimeThrd.Create(true);
  45. newthread1.FreeOnTerminate:=true;
  46. newthread1.filename:=listbox1.Items[0];
  47. newthread1.Resume;
  48. end;
  49. end.
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement