有一个按钮的onclick事件里,是调用一个线程A,现在当连续按n次按钮后,那就会生成n个线程A吧?如果使第一个线程A执行完,再执行第二个线程A,再执行第三个线程A.......再执行第n个线程A?

解决方案 »

  1.   

    有一个按钮的onclick事件里,是调用一个线程A,现在当连续按n次按钮后,那就会生成n个线程A吧?如何使第一个线程A执行完,再执行第二个线程A,再执行第三个线程A.......再执行第n个线程A?
      

  2.   

    你在Button Onclick事件点击进去时将Button1.Enable := False ;
    在线程Terminate事件加入代码
    begin
      Button1.Enable := True ;
      inherited;
    end;
      

  3.   

    我的代码如下:请各位说说,如何解决这问题啊
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls,mmsystem;type
      TForm1 = class(TForm)
        Button1: TButton;
        DataSource1: TDataSource;
        ADOQuery1: TADOQuery;
        DBGrid1: TDBGrid;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
    implementationuses unit2;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
      adoquery1.Edit;
      adoquery1.FieldByName('pa_state').AsString:='2';
      adoquery1.Post;
      adoquery1.Requery;
      TSound.create();
      
    end;end.unit Unit2;interfaceuses
      classes,mmsystem;
    type
      TSound=class(TThread)
      protected
        procedure Execute;override;
      public
        constructor create();
      end;implementation
    uses unit1;constructor TSound.create();
    begin
      FreeOnTerminate:=true;
      inherited Create(false);
    end;procedure TSound.Execute;
    begin
      PlaySound('C:\a.wav',0,SND_SYNC);
      PlaySound('C:\tada.wav',0,SND_SYNC);
    end;end.