R
rackrain
Unregistered / Unconfirmed
GUEST, unregistred user!
现编了一个和银行实时传递数据的接口程序,程序在开始运行时正常,如果数据请示比较多时,程序弹出消息框,上面写out of system resources,但是程序还可以运行,如果动鼠标和键盘,程序就会自动关掉。下面是我的一部分程序,请问问题出在哪里,应该怎么解决??请各位高手看一下。
procedure TForm1.ServerSocketGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
begin
if clientsocket.Connected then
socketthread:=TServerClientThread.Create(clientsocket);
end;
线程内的定义
procedure TServerClientThread.Execute;
var Stream : TWinSocketStream;
buffer1: array[0 .. 1023] of Char;
begin
while (not Terminated) and (client_bank.Connected) do
begin
try
Stream := TWinSocketStream.Create(client_bank, 30000);
FillChar(Buffer1,83, 0);
if Stream.WaitForData(2000) then //等待数据到来
begin
if Stream.Read(Buffer1, 83) = 0 then //读数据
client_bank.Close
else
begin
clientsend:=buffer1;
Synchronize(SendShow);//调用过程
在主程序界面上edit中显示银行传来的数据
case strtoint(copy(clientsend,3,3)) of
110:QuerySend;//对数据库执行查询数据的操作
120:WriteSend;//对数据库执行查询数据的操作
130:CancelSend;//对数据库执行查询数据的操作
end;
If client_bank.Connected Then
begin
//stream.Write(sendbuffer,length(sendstr));
client_bank.SendText(sendstr);
Stream.Free;
client_bank.Close;
end;
end;
end
else
client_bank.Close;
except
client_bank.Close;
Terminate;
//HandleException;
end;
end;
end;
procedure TServerClientThread.SendShow;
begin
form1.snedit1.text:=clientsend;//在主程序界面上edit中显示银行传来的数据
end;
procedure TForm1.ServerSocketGetThread(Sender: TObject;
ClientSocket: TServerClientWinSocket;
var SocketThread: TServerClientThread);
begin
if clientsocket.Connected then
socketthread:=TServerClientThread.Create(clientsocket);
end;
线程内的定义
procedure TServerClientThread.Execute;
var Stream : TWinSocketStream;
buffer1: array[0 .. 1023] of Char;
begin
while (not Terminated) and (client_bank.Connected) do
begin
try
Stream := TWinSocketStream.Create(client_bank, 30000);
FillChar(Buffer1,83, 0);
if Stream.WaitForData(2000) then //等待数据到来
begin
if Stream.Read(Buffer1, 83) = 0 then //读数据
client_bank.Close
else
begin
clientsend:=buffer1;
Synchronize(SendShow);//调用过程
在主程序界面上edit中显示银行传来的数据
case strtoint(copy(clientsend,3,3)) of
110:QuerySend;//对数据库执行查询数据的操作
120:WriteSend;//对数据库执行查询数据的操作
130:CancelSend;//对数据库执行查询数据的操作
end;
If client_bank.Connected Then
begin
//stream.Write(sendbuffer,length(sendstr));
client_bank.SendText(sendstr);
Stream.Free;
client_bank.Close;
end;
end;
end
else
client_bank.Close;
except
client_bank.Close;
Terminate;
//HandleException;
end;
end;
end;
procedure TServerClientThread.SendShow;
begin
form1.snedit1.text:=clientsend;//在主程序界面上edit中显示银行传来的数据
end;