Board index » delphi » TIdTCPServer,TIdPeerThread, its data property and the Terminate Thread Timeout error

TIdTCPServer,TIdPeerThread, its data property and the Terminate Thread Timeout error


2003-09-11 01:19:19 PM
delphi22
I am assigning an instance of a TDataModule descendant to the Data property
of each TIdPeerThread in the OnConnect event handler of my TIdTCPServer
object. If there is a client connected when I set the TCPServer.Active
property to false I always get a Terminate Thread Timeout Error. I am not
freeing the data module myself. I am allowing the thread to do it for me.
If I do not assign anything to the data property the error does not occur.
Besides not assigning anything to the data property, how do I fix this?
I am using Indy 9.00.14 in Delphi 7 on windows XP
Thanks much,
Joel Harris
Ebbhead89
 
 

Re:TIdTCPServer,TIdPeerThread, its data property and the Terminate Thread Timeout error

"Joel Harris" <XXXX@XXXXX.COM>writes
Quote
If there is a client connected when I set the TCPServer.Active
property to false I always get a Terminate Thread Timeout Error.
What does your actual code look like? Are you assigning the same
TDataModule to each thread or are you instantiating a new instance each
time? What is the value of the server's TerminateWaitTime property? Before
getting the timeout, are any of the thread's OnException event being
triggered, by chance?
Gambit
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (www.grisoft.com).
Version: 6.0.515 / Virus Database: 313 - Release Date: 9/1/03
 

Re:TIdTCPServer,TIdPeerThread, its data property and the Terminate Thread Timeout error

"Remy Lebeau (TeamB)" <XXXX@XXXXX.COM>writes
Quote
What does your actual code look like?
Here is the OnConnect event. Let me know if you'd like to see some other
part of the code. At this point in the development of the application the
data module isn't used anywhere else, but it will be.
procedure TMainForm.TCPServerConnect(AThread: TIdPeerThread);
var
ConnStr: string;
dm: TServerDataModule;
begin
ConnStr := StringReplace(CONN_STRING,'[UN]',DBUN,[]);
ConnStr := StringReplace(ConnStr,'[PW]',DBPW,[]);
ConnStr := StringReplace(ConnStr,'[DB]',DB,[]);
ConnStr := StringReplace(ConnStr,'[SERVER]',DBServer,[]);
dm := TServerDataModule.Create(ConnStr, nil);
AThread.Data := dm;
PostMessage(Application.MainForm.Handle, WM_CONN_OPEN, integer(AThread),
AddAtom(PChar(AThread.Connection.LocalName)));
AThread.OnException := testerror;
end;
Quote
Are you assigning the same TDataModule to each thread or are you
instantiating a new instance each
time?
I am instantiating a new instance each time.
Quote
What is the value of the server's TerminateWaitTime property?
The TerminateWaitTime property is set to the default value of 5000
Quote
Before getting the timeout, are any of the thread's OnException event being
triggered, by chance?
No, it appears not to. Thanks for your attention.
 

Re:TIdTCPServer,TIdPeerThread, its data property and the Terminate Thread Timeout error

If itīs not possible for handling Athread.Sychronize(TMethod) have a
look at TCriticalSection. You NEVER should access VCL-Components
during Thread.Execute (f.e. onConnect, onExecute, etc.)
Have a lot of fun:)
Michael:)