function threadfunc(p:pointer):longint;stdcall;
  i:integer;
begin
 while b_flag do
 begin
    //读出特性字节
    i:=Open_Netdog('192.168.0.28',1088);
    sleep(600);
    if (i<>0) then
    begin
      b_flag:=false;
      //在这儿想关闭整个应用程序,请问如何做
    end;
  end;
  result:=0;
end;

解决方案 »

  1.   

    不行的,在线程中用application.Terminate
    根本关不了,我的qq是125782005,在线等,谢谢!!
      

  2.   

    to  WQmeng(我曾经忍耐,我如此等待,也许在等你到来) :
    这样会导致进程的内存得不到释放的。
    建议function threadfunc(p:pointer):longint;stdcall;
      i:integer;
    begin
     while b_flag do
     begin
        //读出特性字节
        i:=Open_Netdog('192.168.0.28',1088);
        sleep(600);
        if (i<>0) then
        begin
          b_flag:=false;
          //在这儿想关闭整个应用程序,请问如何做      //使该进程中止    end;
      end;
      result:=0;
    end;在进程destroy事件中,application.terminate;其实这样也不好,你一定要在线程中终止程序吗?
    我觉得还是在程序中中止好,在程序中判断线程是否结束(可以设置条件使线程退出),如果进程结束就退出程序。
      

  3.   

    建议function threadfunc(p:pointer):longint;stdcall;
      i:integer;
    begin
     while b_flag do
     begin
        //读出特性字节
        i:=Open_Netdog('192.168.0.28',1088);
        sleep(600);
        if (i<>0) then
        begin
          b_flag:=false;
          result := ?  //在程序中根据这个返回值将程序关闭!      //使该进程中止    end;
      end;
      result:=0;
    end;
      

  4.   

    when you need, send a message to the host application,tell it to terminate the thread and himself.
      

  5.   

    planfore(堕落天使) 的解答非常正确