BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Socket connection hangs after connection lost

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Wayne L
Guest





PostPosted: Mon Feb 05, 2007 7:26 pm    Post subject: Socket connection hangs after connection lost Reply with quote



Using D7.1, TSocketConnection, finding that if the connection is destroyed
by a router in some cases when we try to do a query the application hangs
and never comes back, forcing a restart of the app. I have seen other
people describe this issue in these news groups but no answer. Since there
is no timeout feature with TSocketConnction, how do I prevent these hangs? I
played around with using a spearate thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the hang
in the first place, or suggestion on how to use a thread to cause a timeout?
Also has there been any improvement in this with D2006?

Thanks for any help.

Wayne
Back to top
Guillem
Guest





PostPosted: Tue Feb 06, 2007 10:13 pm    Post subject: Re: Socket connection hangs after connection lost Reply with quote



Wayne L wrote:

Quote:
Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
Back to top
Dan Palley
Guest





PostPosted: Tue Feb 06, 2007 11:32 pm    Post subject: Re: Socket connection hangs after connection lost Reply with quote



"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Quote:
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

I'm pretty sure TSocketConnection, like TDCOMConnection, which is part of
Datasnap, is not deprecated.

From the help:

"TSocketConnection is used in the client portion of a multi-tiered database
application to establish and maintain the connection between the client and
a remote application server."

Dan
Back to top
Wayne L
Guest





PostPosted: Tue Feb 06, 2007 11:37 pm    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Not sure these components will play with Datasnap. For example
TSocketConnection lets me find available Datasnap servers once I assign an
IP address and mae a connection. Will I be able to do that with any of these
components? I looked a bit at Indy stuff but do not see these as being a
replacement for TSocketConnection.

Am I missing something?

Wayne

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Quote:
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
Back to top
Dan Palley
Guest





PostPosted: Wed Feb 07, 2007 12:59 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Wayne, you're not missing anything.

You have the source to TSocketConnection. I'd suggest debugging and testing
a dropped connection to see where the app hangs. You may also want to
create an entry in QC to add a timeout capability.

Some of my apps that use TSocketConnection manage the connection in a
thread, so it's fairly simple to kill the connection if it times out.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c8bccd$1 (AT) newsgroups (DOT) borland.com...
Quote:
Not sure these components will play with Datasnap. For example
TSocketConnection lets me find available Datasnap servers once I assign an
IP address and mae a connection. Will I be able to do that with any of
these components? I looked a bit at Indy stuff but do not see these as
being a replacement for TSocketConnection.

Am I missing something?

Wayne

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam


Back to top
Guillem
Guest





PostPosted: Wed Feb 07, 2007 5:31 pm    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Dan Palley wrote:

Quote:

I'm pretty sure TSocketConnection, like TDCOMConnection, which is
part of Datasnap, is not deprecated.

From the help:

"TSocketConnection is used in the client portion of a multi-tiered
database application to establish and maintain the connection between
the client and a remote application server."

Dan

ups, sorry. I confused it with the old Internet components from Borland.

My apologies. Sad
--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
Back to top
Wayne L
Guest





PostPosted: Wed Feb 07, 2007 7:52 pm    Post subject: Re: Socket connection hangs after connection lost Reply with quote

I started playing around with using a thread but it still seems to hang. Not
having played around with threads a lot not sure if I am doing that
correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if the
timer goes off before the thread comes back I suspend the thread and assume
I am offline. But the timer going off never seems to get executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...
Quote:
Wayne, you're not missing anything.

You have the source to TSocketConnection. I'd suggest debugging and
testing a dropped connection to see where the app hangs. You may also
want to create an entry in QC to add a timeout capability.

Some of my apps that use TSocketConnection manage the connection in a
thread, so it's fairly simple to kill the connection if it times out.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c8bccd$1 (AT) newsgroups (DOT) borland.com...
Not sure these components will play with Datasnap. For example
TSocketConnection lets me find available Datasnap servers once I assign
an IP address and mae a connection. Will I be able to do that with any of
these components? I looked a bit at Indy stuff but do not see these as
being a replacement for TSocketConnection.

Am I missing something?

Wayne

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam




Back to top
Dan Palley
Guest





PostPosted: Thu Feb 08, 2007 12:27 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
Quote:
I started playing around with using a thread but it still seems to hang.
Not having played around with threads a lot not sure if I am doing that
correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if the
timer goes off before the thread comes back I suspend the thread and
assume I am offline. But the timer going off never seems to get executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...
Wayne, you're not missing anything.

You have the source to TSocketConnection. I'd suggest debugging and
testing a dropped connection to see where the app hangs. You may also
want to create an entry in QC to add a timeout capability.

Some of my apps that use TSocketConnection manage the connection in a
thread, so it's fairly simple to kill the connection if it times out.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c8bccd$1 (AT) newsgroups (DOT) borland.com...
Not sure these components will play with Datasnap. For example
TSocketConnection lets me find available Datasnap servers once I assign
an IP address and mae a connection. Will I be able to do that with any
of these components? I looked a bit at Indy stuff but do not see these
as being a replacement for TSocketConnection.

Am I missing something?

Wayne

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam






Back to top
Wayne L
Guest





PostPosted: Thu Feb 08, 2007 12:52 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
Quote:
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to hang.
Not having played around with threads a lot not sure if I am doing that
correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if the
timer goes off before the thread comes back I suspend the thread and
assume I am offline. But the timer going off never seems to get executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...
Wayne, you're not missing anything.

You have the source to TSocketConnection. I'd suggest debugging and
testing a dropped connection to see where the app hangs. You may also
want to create an entry in QC to add a timeout capability.

Some of my apps that use TSocketConnection manage the connection in a
thread, so it's fairly simple to kill the connection if it times out.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c8bccd$1 (AT) newsgroups (DOT) borland.com...
Not sure these components will play with Datasnap. For example
TSocketConnection lets me find available Datasnap servers once I assign
an IP address and mae a connection. Will I be able to do that with any
of these components? I looked a bit at Indy stuff but do not see these
as being a replacement for TSocketConnection.

Am I missing something?

Wayne

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the app.
I have seen other people describe this issue in these news groups but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam








Back to top
Dan Palley
Guest





PostPosted: Thu Feb 08, 2007 2:32 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Are you doing any kind of tight loop in your main thread that would prevent
the timer message from being processed?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca1fed$1 (AT) newsgroups (DOT) borland.com...
Quote:
I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to hang.
Not having played around with threads a lot not sure if I am doing that
correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if
the timer goes off before the thread comes back I suspend the thread and
assume I am offline. But the timer going off never seems to get
executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...
Wayne, you're not missing anything.

You have the source to TSocketConnection. I'd suggest debugging and
testing a dropped connection to see where the app hangs. You may also
want to create an entry in QC to add a timeout capability.

Some of my apps that use TSocketConnection manage the connection in a
thread, so it's fairly simple to kill the connection if it times out.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c8bccd$1 (AT) newsgroups (DOT) borland.com...
Not sure these components will play with Datasnap. For example
TSocketConnection lets me find available Datasnap servers once I
assign an IP address and mae a connection. Will I be able to do that
with any of these components? I looked a bit at Indy stuff but do not
see these as being a replacement for TSocketConnection.

Am I missing something?

Wayne

"Guillem" <guillemvicens-nospam (AT) clubgreenoasis (DOT) com> wrote in message
news:45c8a922$1 (AT) newsgroups (DOT) borland.com...
Wayne L wrote:

Using D7.1, TSocketConnection, finding that if the connection is
destroyed by a router in some cases when we try to do a query the
application hangs and never comes back, forcing a restart of the
app.
I have seen other people describe this issue in these news groups
but
no answer. Since there is no timeout feature with TSocketConnction,
how do I prevent these hangs? I played around with using a spearate
thread but found it still hung.

Has anyone figured this one out, either by timing out, preventing
the
hang in the first place, or suggestion on how to use a thread to
cause a timeout? Also has there been any improvement in this with
D2006?


TSocketConnection is technically deprecated. I'd give a try with the
TCP components from either Indy (installed with BDS), Synapse or ICS.

--
Best regards :-)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam










Back to top
Wayne L
Guest





PostPosted: Thu Feb 08, 2007 4:40 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Thought it would easier to just drop the code in. Below is the test code to
start a timer, execute the thread, if the thread finishes turn off the
timer, process results of the thread. Timer interval property is set to
7000.

procedure TFormTestConnectFormSecond.RunATest;
begin
Timer1.Enabled := True;
LThread.Execute;
Timer1.Enabled := False;
LTestResult := LThread.TestResult;
if LTestResult then
LabelStatus.Caption := 'Test good'
else
begin
LabelStatus.Caption := 'Test bad';
Timer2.Enabled := False;
end;
LabelStatus.Update;
LabelLastTime.Caption := TimeToStr(time);
LabelLastTime.Update;
LabelNextTime.Caption := TimeToStr(Time +
(StrToFloat(InfEditInterval.Text) / (24.0 * 60.0)));
LabelLastTime.Update;
end;

If the timer goes off then assume the thread is hung up, turn timer off,
teminate thread, set result to bad.

procedure TFormTestConnectFormSecond.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
LThread.Terminate;
LTestResult := False;
end;

Here is the thread code itself. Execute DoTest which just does a small query
and returns result.

procedure TTestThread.Execute;
begin
Synchronize(DoTest);
end;

procedure TTestThread.DoTest;
begin
TestResult := False;
try
CDS.Active := False;
CDS.Active := True;
CDS.Active := False;
TestResult := True;
except
TestResult := False;
end;
end;

Thanks for looking at this.

Wayne


"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca1fed$1 (AT) newsgroups (DOT) borland.com...
Quote:
I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to hang.
Not having played around with threads a lot not sure if I am doing that
correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if
the timer goes off before the thread comes back I suspend the thread and
assume I am offline. But the timer going off never seems to get
executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...





Back to top
Dan Palley
Guest





PostPosted: Thu Feb 08, 2007 6:44 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Your call to LThread.Execute will always return immediately so the timer
will never fire.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca553d$1 (AT) newsgroups (DOT) borland.com...
Quote:
Thought it would easier to just drop the code in. Below is the test code
to start a timer, execute the thread, if the thread finishes turn off the
timer, process results of the thread. Timer interval property is set to
7000.

procedure TFormTestConnectFormSecond.RunATest;
begin
Timer1.Enabled := True;
LThread.Execute;
Timer1.Enabled := False;
LTestResult := LThread.TestResult;
if LTestResult then
LabelStatus.Caption := 'Test good'
else
begin
LabelStatus.Caption := 'Test bad';
Timer2.Enabled := False;
end;
LabelStatus.Update;
LabelLastTime.Caption := TimeToStr(time);
LabelLastTime.Update;
LabelNextTime.Caption := TimeToStr(Time +
(StrToFloat(InfEditInterval.Text) / (24.0 * 60.0)));
LabelLastTime.Update;
end;

If the timer goes off then assume the thread is hung up, turn timer off,
teminate thread, set result to bad.

procedure TFormTestConnectFormSecond.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
LThread.Terminate;
LTestResult := False;
end;

Here is the thread code itself. Execute DoTest which just does a small
query and returns result.

procedure TTestThread.Execute;
begin
Synchronize(DoTest);
end;

procedure TTestThread.DoTest;
begin
TestResult := False;
try
CDS.Active := False;
CDS.Active := True;
CDS.Active := False;
TestResult := True;
except
TestResult := False;
end;
end;

Thanks for looking at this.

Wayne


"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca1fed$1 (AT) newsgroups (DOT) borland.com...
I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to hang.
Not having played around with threads a lot not sure if I am doing that
correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if
the timer goes off before the thread comes back I suspend the thread
and assume I am offline. But the timer going off never seems to get
executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...







Back to top
Wayne L
Guest





PostPosted: Thu Feb 08, 2007 8:51 pm    Post subject: Re: Socket connection hangs after connection lost Reply with quote

I checked out the demo provided with Delphi 7 on a background query. So
should I be just creating the thread, not in suspend mode, so it executes on
its own without using Execute? In the demo I see it uses FreeOnTerminate so
the thread destroys itself when done. How do I pass back whether the query
completed or did not complete? I am not interested in the results just
whether the query worked or not.

Thanks.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca72c5$1 (AT) newsgroups (DOT) borland.com...
Quote:
Your call to LThread.Execute will always return immediately so the timer
will never fire.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca553d$1 (AT) newsgroups (DOT) borland.com...
Thought it would easier to just drop the code in. Below is the test code
to start a timer, execute the thread, if the thread finishes turn off the
timer, process results of the thread. Timer interval property is set to
7000.

procedure TFormTestConnectFormSecond.RunATest;
begin
Timer1.Enabled := True;
LThread.Execute;
Timer1.Enabled := False;
LTestResult := LThread.TestResult;
if LTestResult then
LabelStatus.Caption := 'Test good'
else
begin
LabelStatus.Caption := 'Test bad';
Timer2.Enabled := False;
end;
LabelStatus.Update;
LabelLastTime.Caption := TimeToStr(time);
LabelLastTime.Update;
LabelNextTime.Caption := TimeToStr(Time +
(StrToFloat(InfEditInterval.Text) / (24.0 * 60.0)));
LabelLastTime.Update;
end;

If the timer goes off then assume the thread is hung up, turn timer off,
teminate thread, set result to bad.

procedure TFormTestConnectFormSecond.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
LThread.Terminate;
LTestResult := False;
end;

Here is the thread code itself. Execute DoTest which just does a small
query and returns result.

procedure TTestThread.Execute;
begin
Synchronize(DoTest);
end;

procedure TTestThread.DoTest;
begin
TestResult := False;
try
CDS.Active := False;
CDS.Active := True;
CDS.Active := False;
TestResult := True;
except
TestResult := False;
end;
end;

Thanks for looking at this.

Wayne


"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca1fed$1 (AT) newsgroups (DOT) borland.com...
I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to
hang. Not having played around with threads a lot not sure if I am
doing that correctly.

Basically I createda thread, I pass a clientdataset to it. I started a
timer, execute the thread, the thread executes a small test query, if
the timer goes off before the thread comes back I suspend the thread
and assume I am offline. But the timer going off never seems to get
executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...









Back to top
Dan Palley
Guest





PostPosted: Fri Feb 09, 2007 1:52 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

What you need to do is move the code for initiating, testing, and completing
the thread into different methods. For example, the thread creation and
timer kick-off could be the result of a button push. When the thread
finishes, it could suspend itself and send a message to the main thread
indicating it's done. The timer invocation could check the thread status
and kill it if it's still running.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45cb38e5$1 (AT) newsgroups (DOT) borland.com...
Quote:
I checked out the demo provided with Delphi 7 on a background query. So
should I be just creating the thread, not in suspend mode, so it executes
on its own without using Execute? In the demo I see it uses FreeOnTerminate
so the thread destroys itself when done. How do I pass back whether the
query completed or did not complete? I am not interested in the results
just whether the query worked or not.

Thanks.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca72c5$1 (AT) newsgroups (DOT) borland.com...
Your call to LThread.Execute will always return immediately so the timer
will never fire.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca553d$1 (AT) newsgroups (DOT) borland.com...
Thought it would easier to just drop the code in. Below is the test code
to start a timer, execute the thread, if the thread finishes turn off
the timer, process results of the thread. Timer interval property is set
to 7000.

procedure TFormTestConnectFormSecond.RunATest;
begin
Timer1.Enabled := True;
LThread.Execute;
Timer1.Enabled := False;
LTestResult := LThread.TestResult;
if LTestResult then
LabelStatus.Caption := 'Test good'
else
begin
LabelStatus.Caption := 'Test bad';
Timer2.Enabled := False;
end;
LabelStatus.Update;
LabelLastTime.Caption := TimeToStr(time);
LabelLastTime.Update;
LabelNextTime.Caption := TimeToStr(Time +
(StrToFloat(InfEditInterval.Text) / (24.0 * 60.0)));
LabelLastTime.Update;
end;

If the timer goes off then assume the thread is hung up, turn timer off,
teminate thread, set result to bad.

procedure TFormTestConnectFormSecond.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
LThread.Terminate;
LTestResult := False;
end;

Here is the thread code itself. Execute DoTest which just does a small
query and returns result.

procedure TTestThread.Execute;
begin
Synchronize(DoTest);
end;

procedure TTestThread.DoTest;
begin
TestResult := False;
try
CDS.Active := False;
CDS.Active := True;
CDS.Active := False;
TestResult := True;
except
TestResult := False;
end;
end;

Thanks for looking at this.

Wayne


"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca1fed$1 (AT) newsgroups (DOT) borland.com...
I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to
hang. Not having played around with threads a lot not sure if I am
doing that correctly.

Basically I createda thread, I pass a clientdataset to it. I started
a timer, execute the thread, the thread executes a small test query,
if the timer goes off before the thread comes back I suspend the
thread and assume I am offline. But the timer going off never seems
to get executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...











Back to top
Wayne L
Guest





PostPosted: Sat Feb 10, 2007 12:01 am    Post subject: Re: Socket connection hangs after connection lost Reply with quote

Got it, will give that a try. Thanks for helping out, appreciate it.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45cb8009$1 (AT) newsgroups (DOT) borland.com...
Quote:
What you need to do is move the code for initiating, testing, and
completing the thread into different methods. For example, the thread
creation and timer kick-off could be the result of a button push. When
the thread finishes, it could suspend itself and send a message to the
main thread indicating it's done. The timer invocation could check the
thread status and kill it if it's still running.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45cb38e5$1 (AT) newsgroups (DOT) borland.com...
I checked out the demo provided with Delphi 7 on a background query. So
should I be just creating the thread, not in suspend mode, so it executes
on its own without using Execute? In the demo I see it uses
FreeOnTerminate so the thread destroys itself when done. How do I pass
back whether the query completed or did not complete? I am not interested
in the results just whether the query worked or not.

Thanks.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca72c5$1 (AT) newsgroups (DOT) borland.com...
Your call to LThread.Execute will always return immediately so the timer
will never fire.

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca553d$1 (AT) newsgroups (DOT) borland.com...
Thought it would easier to just drop the code in. Below is the test
code to start a timer, execute the thread, if the thread finishes turn
off the timer, process results of the thread. Timer interval property
is set to 7000.

procedure TFormTestConnectFormSecond.RunATest;
begin
Timer1.Enabled := True;
LThread.Execute;
Timer1.Enabled := False;
LTestResult := LThread.TestResult;
if LTestResult then
LabelStatus.Caption := 'Test good'
else
begin
LabelStatus.Caption := 'Test bad';
Timer2.Enabled := False;
end;
LabelStatus.Update;
LabelLastTime.Caption := TimeToStr(time);
LabelLastTime.Update;
LabelNextTime.Caption := TimeToStr(Time +
(StrToFloat(InfEditInterval.Text) / (24.0 * 60.0)));
LabelLastTime.Update;
end;

If the timer goes off then assume the thread is hung up, turn timer
off, teminate thread, set result to bad.

procedure TFormTestConnectFormSecond.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
LThread.Terminate;
LTestResult := False;
end;

Here is the thread code itself. Execute DoTest which just does a small
query and returns result.

procedure TTestThread.Execute;
begin
Synchronize(DoTest);
end;

procedure TTestThread.DoTest;
begin
TestResult := False;
try
CDS.Active := False;
CDS.Active := True;
CDS.Active := False;
TestResult := True;
except
TestResult := False;
end;
end;

Thanks for looking at this.

Wayne


"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45ca1fed$1 (AT) newsgroups (DOT) borland.com...
I had set it to 7 seconds, or 7000 in the property.

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45ca1a7a$1 (AT) newsgroups (DOT) borland.com...
What do you have as the interval for the timer?

Dan

"Wayne L" <wloeppky500 (AT) shaw (DOT) ca> wrote in message
news:45c9d9a0$1 (AT) newsgroups (DOT) borland.com...
I started playing around with using a thread but it still seems to
hang. Not having played around with threads a lot not sure if I am
doing that correctly.

Basically I createda thread, I pass a clientdataset to it. I started
a timer, execute the thread, the thread executes a small test query,
if the timer goes off before the thread comes back I suspend the
thread and assume I am offline. But the timer going off never seems
to get executed.

Any thoughts on what I am doing wrong with the thread?

Wayne

"Dan Palley" <dan (AT) trams (DOT) com> wrote in message
news:45c8d07d$1 (AT) newsgroups (DOT) borland.com...













Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.