Re: TCPServer & MSSQL & Threads (Newbie Question)
- From: "Mark Moss" <markmoss@xxxxxxxxxxxx>
- Date: Mon, 21 Apr 2008 08:40:23 -0600
Would Someone PLEASE answer the TWO followon questions that I have.
Mark Moss
"Mark Moss" <markmoss@xxxxxxxxxxxx> wrote in message
news:4807dc67$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Ladies / Gentlemen
I am new to Thread Programming, so please bear with me.
Below is Code from Chad Z. Hower, ( aka "Kudzu" ) book "Indy in
Depth" that is supposed to be Thread Safe.
The Sleep(5000) is supposed to represent the SQL statements.
What I need to know is the proper way to execute SQL code thru
components that are located on a DataModule and the proper way to declare
GlobalVariables so that they are unique to each Thread.
Do I Declare the GlobalVariables in the interface section under a
Threadvar such as
var
Form1: TForm1;
ThreadVar
x : integer;
{-----------------------------------------------------------------------------------------------------------------}
And do I have to Create the DataModule and all of the components on
it for each Thread. If not what do I do?
Any HELP that you can give me will be greatly appreciated.
Mark Moss
{-----------------------------------------------------------------------------------------------------------------}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPServer;
type
TForm1 = class(TForm)
IdTCPServer1: TIdTCPServer;
procedure IdTCPServer1Execute(AThread: TIdPeerThread);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
i : integer;
begin
with AThread.Connection do
begin
WriteLn('Hello. DB Server Ready.');
i := StrToIntDef(ReadLn, 0);
Sleep(5000);
WriteLn(IntToStr( i * 7 ));
Disconnect;
end;
end;
end.
{---------------------------------------------------------------------------------------------------------}
.
- References:
- TCPServer & MSSQL & Threads (Newbie Question)
- From: Mark Moss
- TCPServer & MSSQL & Threads (Newbie Question)
- Prev by Date: Re: ADO Excel D2007 SQL UPDATE problem
- Next by Date: Is This Thread Safe?
- Previous by thread: Re: TCPServer & MSSQL & Threads (Newbie Question)
- Next by thread: ADOQuery exception on empty dataset
- Index(es):
Relevant Pages
|