点击保存按钮后,将相应数据提交到mssql数据库,但是在提交的过程中,界面不动,不能进行任何操作了,必须等保存完才可以动。据说可以用线程实现,不知道怎么弄,请给我个例子,谢谢,

解决方案 »

  1.   

    使用多线程操作就可以了
    置顶的帖子你看看吧
    http://topic.csdn.net/u/20110217/11/56577c65-2e77-4f8f-b541-0be47cdb4d60.html?96425
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
        procedure DoInThread(Sender: TObject);
      end;var
      Form1: TForm1;implementation{$R *.dfm}type
      TProc = procedure(Sender: TObject) of object;  TMyThread = class(TThread)
        proc: TProc;
        procedure Execute; override;
      end;{ TMyThread }procedure TMyThread.Execute;
    begin
      inherited;
      FreeOnTerminate := True;
      //提交的过程放在此处
      if Assigned(proc) then proc(Self)
      
    end;procedure TForm1.DoInThread(Sender: TObject);
    begin
      Sleep(10000);//此处模拟耗时的操作
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      ShowMessage('a');
      with TMyThread.Create(True) do
      begin
        proc := DoInThread;//在线程中执行,不会卡
        Resume;
      end;
      ShowMessage('b');
    end;end.
      

  3.   

    一般来说就扔到线程里面.也可以    application.ProcessMessages