Re: TCPServer & MSSQL & Threads (Newbie Question)



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.

{---------------------------------------------------------------------------------------------------------}




.



Relevant Pages

  • TCPServer & MSSQL & Threads (Newbie Question)
    ... components that are located on a DataModule and the proper way to declare ...
    (borland.public.delphi.database.ado)
  • Re: function pointers vs direct calling in javascript
    ... scope tree to look for 'tempVar2' or for some other reason? ... Here is what I think of 'var', correct me if I am wrong. ... 'var' doesn't as such declare a variable. ... a property of the global object when the code executes. ...
    (comp.lang.javascript)
  • Re: MDIForm Parent/Child forms BEST Practice
    ... First i always create a public var of my main form (mdi parent) for easy ... access (yust declare it in a module and i the parent.load set the var to me) ... Private Sub frmMain_Closed(ByVal sender As Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Library not opening...?
    ... once in form's var section and once in method, ... In Form's Init you open and assing global variable, ... declare variables in form's var section ... > Form's Var block, and opened only in the Form's Init. ...
    (comp.databases.paradox)
  • Re: How much would variable declarations in Ruby make you wince?
    ... languages that require variables to be declared or typed. ... How on God's green Earth are you going to accidentally prepend an ... only happen if you accidentally want to declare a new variable. ... until "var" is the norm; ...
    (comp.lang.ruby)