程序一开始就加载数据模块:
Application.Initialize;
Application.CreateForm(TDataMod, DataMod);TDataMod中有一个ADOConnection,我在TDataMod的onCreate中尝试能否脸上数据库,不能连上就关闭程序:
ADOConnection1.ConnectionString:='Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=stusys;Data Source=GENIUS1;';        try
        self.ADOConnection1.Open;
        except
        on E:Exception do
        begin
              showMessage('请检查SQL SERVER 是否启动或网络是否连通');
              application.Terminate;   
        end;
        end;
可是出现异常后,弹出对话框提示,关闭对话框,理应程序退出,可是它的进程仍然存在大约一分钟‘当’了一声后才退出
有人能告诉我为什么,和解决的原因么?谢谢

解决方案 »

  1.   

    application.Terminate; 时发送了一个关闭消息给全部;要等其它部分都释放万资源才能关掉
      

  2.   

    用halt代替application.Terminate; 试试
      

  3.   

    用halt代替application.Terminate; 试试绝对同意!!!
      

  4.   

    Call Terminate to end the application programmatically. By calling Terminate rather than freeing the application object, you allow the application to shut down in an orderly fashion.Halt performs an abnormal termination of a program and returns to the operating system. To perform a normal termination of an application, call Application.Terminate. Exitcode is an optional expression that specifies an exit code for the program.
      

  5.   

    原因是应用程序需要继续执行其它的语句,如:Application.CreateForm(TForm1, Form1);你可以在判断数据库无法连接时,直接使用Exit退出,如:if(Form1.Tag = 5) then
        exit;
      

  6.   

    halt的却快了很多,但他有没有副作用呢?“Halt performs an abnormal termination of a program and returns to the operating system”to:cscer(石头)
    Form1.Tag = 5是什么意思?
      

  7.   

    手动释放一把adoConnection,
    可能会好些
      

  8.   

    windows要按顺序处理消息, 消息队列showMessage('请检查SQL SERVER 是否启动或网络是否连通');
    Application.Processmessage;
    application.Terminate; 试试?
      

  9.   

    如果非要用application.Terminate; 
    那么请先判断一下:application.Terminated; 的值
      

  10.   

    把Application.CreateForm(TDataMod, DataMod);放在主窗口创建语句之后。
      

  11.   

    // 试试 :  Application.MessageBox(PChar('请检查SQL SERVER 是否启动或网络是否连通'),'Wrong',Mb_Ok + Mb_IconError);
      application.Terminate ; // 或者 Halt ;   
      

  12.   

    TO  xpaul(paul)
      form.tag:=5是设置TAG属性..TAG可以放任一类型的数据..用sendmessage(application.handle,WM_CLOSE,0);
    试试..
      

  13.   

    呵呵,会不会是要等ADOConnection的连接超时过后才关?