J
jacob0076
Unregistered / Unconfirmed
GUEST, unregistred user!
我的线程如下,即使把ClientDataset的open过程在进程中打开也会出现有时候在open处停止响应的问题,请大侠们指点指点吧!
unit UQueryThread;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
npublicMisc,npublicStrAndTstr,npublicFileAndDir,npublicSQLStr,npublicDBVcl,
npublicTstrSection,npublicTreeview,npublicNonDBVcl,dbclient,UShowInfo,
db,dbtables,dbgrids,UTsystbl0,UTsystbl1,UTsystbl2p1,SConnect;
type
TQueryThread = class(TThread)
private
public
Fsoc: TSocketConnection;
FCDS:TClientDataSet;
Running:boolean;
constructor Create(CDS1:TClientDataSet;soc: TSocketConnection;SQL:string);
destructor Destroy;
override;
protected
procedure Execute;override;
end;
implementation
{ TQueryThread }
constructor TQueryThread.Create(CDS1:TClientDataSet;soc: TSocketConnection;SQL:string);
begin
FreeOnTerminate:=false;
Fsoc:=TSocketConnection.Create(application);
FSoc.Address:=soc.Address;
FSoc.Host:=soc.Host;
FSoc.Port:=soc.Port;
FSoc.ServerName:=soc.ServerName;
Fsoc.ServerGUID:=soc.ServerGUID;
FCDS:=TClientDataSet.Create(application);
FCDS.RemoteServer:=Fsoc;
FCDS.CommandText:=SQL;
FCDS.PacketRecords:=CDS1.PacketRecords;
FCDS.ProviderName:=CDS1.ProviderName;
inherited Create(true);
end;
destructor TQueryThread.Destroy;
begin
FSOC.Connected:=false;
FCDS.Close;
FreeAndNil(FCDS);
FreeAndNil(FSOC);
inherited;
end;
procedure TQueryThread.Execute;
begin
Running:=true;
try
Fsoc.Connected:=true;
FCDS.Open;//有时候到这里就不继续往下做了,程序也失去响应了,要强行关闭才行
Running:=false;
finally
end;
end;
end.
unit UQueryThread;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
npublicMisc,npublicStrAndTstr,npublicFileAndDir,npublicSQLStr,npublicDBVcl,
npublicTstrSection,npublicTreeview,npublicNonDBVcl,dbclient,UShowInfo,
db,dbtables,dbgrids,UTsystbl0,UTsystbl1,UTsystbl2p1,SConnect;
type
TQueryThread = class(TThread)
private
public
Fsoc: TSocketConnection;
FCDS:TClientDataSet;
Running:boolean;
constructor Create(CDS1:TClientDataSet;soc: TSocketConnection;SQL:string);
destructor Destroy;
override;
protected
procedure Execute;override;
end;
implementation
{ TQueryThread }
constructor TQueryThread.Create(CDS1:TClientDataSet;soc: TSocketConnection;SQL:string);
begin
FreeOnTerminate:=false;
Fsoc:=TSocketConnection.Create(application);
FSoc.Address:=soc.Address;
FSoc.Host:=soc.Host;
FSoc.Port:=soc.Port;
FSoc.ServerName:=soc.ServerName;
Fsoc.ServerGUID:=soc.ServerGUID;
FCDS:=TClientDataSet.Create(application);
FCDS.RemoteServer:=Fsoc;
FCDS.CommandText:=SQL;
FCDS.PacketRecords:=CDS1.PacketRecords;
FCDS.ProviderName:=CDS1.ProviderName;
inherited Create(true);
end;
destructor TQueryThread.Destroy;
begin
FSOC.Connected:=false;
FCDS.Close;
FreeAndNil(FCDS);
FreeAndNil(FSOC);
inherited;
end;
procedure TQueryThread.Execute;
begin
Running:=true;
try
Fsoc.Connected:=true;
FCDS.Open;//有时候到这里就不继续往下做了,程序也失去响应了,要强行关闭才行
Running:=false;
finally
end;
end;
end.