procedure TValidThread.Execute;
var
UserName:string;
UserPass:string;
ConnThread:Pointer;
BuffSendData:Array[1..16] of char;
i,j:integer;
AdoConn:TAdoConnection;
AdoQry:TAdoQuery;
UserValid:Boolean;
begin
 CoInitialize(NIL);
 AdoConn:=TAdoConnection.Create(NIL);
 AdoQry:=TAdoQuery.Create(NIL);
 AdoConn.ConnectionString:=frmvaliduser.StrConnect;
 AdoConn.LoginPrompt:=False;
 AdoConn.Connected:=True;
 AdoQry.Connection:=AdoConn;
 While frmvalidUser.idIsUserValid.Active do
  begin
   if DeQueue(MyQueue,UserName,Userpass,ConnThread) then
    begin
     j:=GetTickCount();
     try
      UserValid:=False;
      ZeroMemory(@BuffSendData,16);
      try
       AdoQry.Active:=False;
       AdoQry.SQL.Clear;
       AdoQry.SQL.Add('Select * from userdata where 用户姓名='''+UserName+''''+' AND 用户密码='''+UserPass+'''');
       AdoQry.Active:=True;
       if AdoQry.isempty=False then
        begin
         UserValid:=True;
        end
       else
        begin
         UserValid:=False;
        end;
      except
      end;
      j:=GetTickCount()-j;
      frmvaliduser.Label9.Caption:=inttostr(j);
      if UserValid then
       begin
        try
         BuffSendData[1]:='S';
         TIdPeerThread(ConnThread).Connection.WriteBuffer(BuffSendData,16,True);
        except
        end;
       end
      else
       begin
        try
         BuffSendData[1]:='F';
         TIdPeerThread(ConnThread).Connection.WriteBuffer(BuffSendData,16,True);
        except
        end;
       end;
     finally
      try
        TIdPeerThread(ConnThread).Connection.Disconnect;
      except
      end;
     end;
     sleep(5);
    end
   else
    sleep(10);
  end;
 AdoQry.Close;
 AdoQry.Destroy;
 AdoConn.Close;
 AdoConn.Destroy;
 CoInitialize(NIL);
end;
这个线程里的数据库查询代码的执行过程明显比正常的查询过程慢,不明白为什么