我的程序里有3 个timer,都是每隔十几秒做一些动作,在关闭窗体时,常常关了窗口,那些timer动作还在继续,有时候点了关闭窗口按钮,也得等好几秒钟才能关闭,有时候甚至卡住了 
     请问,应该怎么做,才能在我关闭窗口时,所有的timer事件全部结束,不要卡住窗口

解决方案 »

  1.   

    使用Timer是同步运行的,如果需要点击关闭窗口就关闭,尝试使用多线程
      

  2.   

    在循环中加Application.ProcessMessages; 覆盖WndProc过程来处理WM_CLOSE消息,强制退出Delphi(Pascal) code
    type
      TForm1 = class(TForm)
      private
        procedure WndProc(var MSg: TMessage); Override;
      public
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.WndProc(var MSg: TMessage);
    begin
      inherited;
      if msg.Msg = WM_Close then
        halt;
    end;最好的办法就是使用多线程