yes, you do need a sepetate TSession per thread - each database usually
shares a single one, hence the problem.

N
----- Original Message -----
From: "Donovan J. Edye" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Monday, October 08, 2001 3:54 PM
Subject: Re: [DUG]: [Q] MIDAS (Socket Connection), BDE, Threads


> R,
>
> Sorry. Part II. Is a TSession still necessary even though the thread and
> the application have their own TDatabase components and inherently their
> own Session?
>
> At 15:50 08/10/2001 +1300, you wrote:
> >I have no idea about how MIDAS works but you definately need to use a
> >seperate session with each thread when working with DBase etc.  As to BDE
> >crashes, me too!  Any app that crashes the BDE will crash any other app
> >using the BDE in my experiance.
> >
> >Robert Martin
> >Software Engineer
> >Wild Software Ltd
> >>----- Original Message -----
> >>From: <mailto:[EMAIL PROTECTED]>Donovan J. Edye
> >>To: <mailto:[EMAIL PROTECTED]>Multiple recipients of list delphi
> >>Sent: Monday, October 08, 2001 2:49 PM
> >>Subject: [DUG]: [Q] MIDAS (Socket Connection), BDE, Threads
> >>
> >>G'Day All,
> >>
> >>I have the following:
> >>
> >>- A component TCricketLiveScoringClient that uses a MIDAS socket
> >>connection to make and handle a connection to a MIDAS server
> >>- The above component uses a TTXProcessThread to monitor changes in a
> >>local BDE table
> >>- When a change is detected by the it uses
> >>TCricketLiveScoringClient.ProcessTX() to send the transaction to the
> >>MIDAS server
> >>
> >>However what I am finding is that if an exception is raised and the
> >>thread terminated and the connection to the MIDAS server closed that the
> >>application dies horribly with access violation(s), runtime error 216
> >>etc. So my questions are these:
> >>
> >>- The thread uses its own TDatabase connection (and not the TDatabase
> >>connection of the application that contains the component). But does it
> >>require a TSession component as well? Are there issues here to do with
> >>the BDE/Threading?
> >>- It appears to me that the AppServer property of the TSocketConnection
> >>"disappears" out from under me. However no amount of:
> >>
> >>       if not ((VarIsNull(FSocketConnection.AppServer)) AND (varEmpty =
> >> VarType(FSocketConnection.AppServer)) AND
> >>          (varNull = VarType(FSocketConnection.AppServer))) then
> >>seems to protect me from getting the access violation.
> >>
> >>Can anybody provide me with some pointers etc.? Below find the necessary
> >>code, but if you need anything else then please ask. I am at a loss as
to
> >>how to solve this. Environment is D5.01 Enterprise.
> >>
> >>TIA
> >>
> >>
> >>type
> >>    TNewTXDataEvent = procedure(ATXID : integer; ATXPayload : string;
> >> TotalTXs : integer;
> >>       var EventCompleted : boolean; var EventCompletedSuccessfully :
> >> boolean) of object;
> >>
> >>    TTXProcessThread = class(TThread)
> >>    private
> >>       FDatabase : TDataBase;
> >>       FEventCompleted : boolean;
> >>       FEventCompletedSuccessfully : boolean;
> >>       FLastTxIDProcessed : integer;
> >>       //FSession : TSession;
> >>       FTXTable : TTable;
> >>       FNewTXDataEvent : TNewTXDataEvent;
> >>    protected
> >>       procedure Execute; override;
> >>       procedure FireCallBackEvent;
> >>    public
> >>       constructor Create(CreateSuspended : Boolean; ADBPath : string;
> >>          AStartTXID : integer; ANewTXData : TNewTXDataEvent);
> >>       destructor Destroy; override;
> >>    end;
> >>
> >>type
> >>    TCricketLiveScoringClient = class(TCustomPanel)
> >>    private
> >>       FActive : boolean;
> >>       FCricketAppGUID : string;
> >>       FGlobalMatchCode : string;
> >>       FLastTXProcessed : integer;
> >>       FSocketConnection : TSocketConnection;
> >>       FStatusPanel : TPanel;
> >>       FTXPanel : TPanel;
> >>       FMessages : TStringList;
> >>       FTXProcessingThread : TTXProcessThread;
> >>       FClientIP : string;
> >>       FDBPath : string;
> >>       FLoggedIn : boolean;
> >>       FMidasServerPort : SmallInt;
> >>       FMidasServerAddress : string;
> >>       procedure AddMessage(AMsg : string);
> >>       procedure CustomOnDblClick(Sender : TObject);
> >>       function Get_Local_IPAddr : string;
> >>       procedure HandleExceptionError(AProcName, AErr, ADelphiError :
> >> string);
> >>       function Login : boolean;
> >>       function Logout : boolean;
> >>       procedure NewDataEvent(ATXID : integer; ATXPayload : string;
> >> TotalTXs : integer;
> >>          var EventCompleted : boolean; var EventCompletedSuccessfully :
> >> boolean);
> >>       function ProcessTX(AGlobalMatchCode : string; ATXID : Integer;
> >>          const ATXPayload : string; var ANextTXID : Integer;
> >>          var ASQLServerErrroCode : integer; var ASQLServerErrorDesc :
> >> string) : WordBool;
> >>       procedure SetActive(const Value : boolean);
> >>       procedure SetGlobalMatchCode(const Value : string);
> >>       procedure SetMidasServerAddress(const Value : string);
> >>       procedure SetMidasServerPort(const Value : SmallInt);
> >>    protected
> >>
> >>    public
> >>       constructor Create(AOwner : TComponent); override;
> >>       destructor Destroy; override;
> >>    published
> >>       property Active : boolean read FActive write SetActive;
> >>       property Align;
> >>       property BevelInner;
> >>       property BevelOuter;
> >>       property CricketAppGUID : string read FCricketAppGUID write
> >> FCricketAppGUID;
> >>       property GlobalMatchCode : string read FGlobalMatchCode write
> >> SetGlobalMatchCode;
> >>       property DBPath : string read FDBPath write FDBPath;
> >>       property MidasServerAddress : string read FMidasServerAddress
> >> write SetMidasServerAddress;
> >>       property MidasServerPort : SmallInt read FMidasServerPort write
> >> SetMidasServerPort;
> >>    end;
> >>
> >>
> >>function TCricketLiveScoringClient.ProcessTX(AGlobalMatchCode : string;
> >>ATXID : Integer;
> >>    const ATXPayload : string; var ANextTXID : Integer;
> >>    var ASQLServerErrroCode : integer; var ASQLServerErrorDesc : string)
> >> : WordBool;
>
>>//////////////////////////////////////////////////////////////////////////
//////
> >>// PURPOSE: Processes the supplied TX information
> >>const
> >>    PROC_NAME = 'TCricketLiveScoringClient.ProcessTX';
> >>    ERR_MSG = 'I was unable to process the transaction.';
> >>begin
> >>    //Show failure at this point
> >>    result := FALSE;
> >>    try
> >>       if not ((VarIsNull(FSocketConnection.AppServer)) AND (varEmpty =
> >> VarType(FSocketConnection.AppServer)) AND
> >>          (varNull = VarType(FSocketConnection.AppServer))) then
> >>       begin
> >>          if FSocketConnection.AppServer.ProcessTX(FClientIP,
> >> FCricketAppGUID, AGlobalMatchCode, ATXID,
> >>             ATXPayload, ANextTXID, ASQLServerErrroCode,
> >> ASQLServerErrorDesc) = WordBool(TRUE) then
> >>          begin
> >>             result := TRUE;
> >>             FLastTXProcessed := ANextTXID - 1;
> >>          end;
> >>       end;
> >>    except
> >>       on E : Exception do
> >>          HandleExceptionError(PROC_NAME, ERR_MSG, E.Message);
> >>    end;
> >>end;
> >>
> >>
> >>-- Donovan
> >>----------------------------------------------------------------------
> >>Donovan J. Edye [www.edye.wattle.id.au]
> >>Namadgi Systems [www.namsys.com.au]
> >>Voice: +61 2 6285-3460
> >>Fax: +61 2 6285-3459
> >>TVisualBasic = Class(None);
> >>Heard just before the 'Big Bang': "...Uh Oh...."
> >>----------------------------------------------------------------------
> >>GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
> >>replacement. Also includes freeware delphi windows explorer components.
> >>----------------------------------------------------------------------
> >
> >-- Donovan
> >----------------------------------------------------------------------
> >Donovan J. Edye [www.edye.wattle.id.au]
> >Namadgi Systems [www.namsys.com.au]
> >Voice: +61 2 6285-3460
> >Fax: +61 2 6285-3459
> >TVisualBasic = Class(None);
> >Heard just before the 'Big Bang': "...Uh Oh...."
> >----------------------------------------------------------------------
> >GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
> >replacement. Also includes freeware delphi windows explorer components.
> >----------------------------------------------------------------------
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to