现在的位置: 首页 > 综合 > 正文

多线程问题?!!高手来

2013年04月09日 ⁄ 综合 ⁄ 共 1292字 ⁄ 字号 评论关闭
多线程问题?!!高手来 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiAPI/html/delphi_20061110202423255.html
一个函数  
  funtion   temp(aa:integer;bb:integer):string;  
  var  
    i,j:integer;  
  begin  
  for   i=0   to   aa   do  
    begin  
      for   j=0   to   bb   do  
        begin  
          string:=string+string;  
        end;  
    end;  
  result:=string;  
  end;  
  两个按钮都调用该函数,就是传入的参数不同,第一个按钮temp(1000,1000),第二个temp(10000,10000)  
   
  如何用多线程来分别调用啊,酒是没两个按扭可以连续的点击,不需要一个处理完了才能继续点;  
  而且还有得到返回的变量!!!!!

>>如何用多线程来分别调用啊,  
   
  你从Thread继承两个线程类,在类的Execute中调用temp就可以了,

详细点啊,最好有代码啊

又遇到一位不求上进的懒人。  
   
  TMyThread   =   class(TThread)  
      private  
          FA:   Integer;  
          FB:   Integer;  
          function   Temp(aa:integer;   bb:integer):string;  
      protected  
          procedure   Execute;   override;  
      public  
          constructor   Create(const   AA,   AB:   Integer);   reintroduce;  
      end;  
   
   
  constructor   TMyThread.Create(const   AA,   AB:   Integer;   AE:   TEdit);  
  begin  
      FreeOnTerminate   :=   True;  
      inherited   create(True);  
      FA   :=   AA;  
      FB   :=   AB;  
  end;  
   
  procedure   TMyThread.Execute;  
  begin  
      inherited;  
      Temp(FA,   FB);  
  end;  
   
  ..........  
  procedure   TForm1.Button1Click(Sender:   TObject);  
  begin  
      with   TMyThread.Create(100,   100)   do  
        Resume;  
  end;  
   
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  begin  
      with   TMyThread.Create(1000,   1000)   do  
        Resume;  
  end;  
   
 

这里只是一个基本框架,至于实际项目和同步显示还有许多工作要做,你自己慢慢学习吧!

抱歉!评论已关闭.