Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Nov : Big problem with "tthread.suspended" under Windows 2003 server
| Subject: | Big problem with "tthread.suspended" under Windows 2003 server |
| Posted by: | "Arthur Hoornweg" (antispam.hoornweg@casema.nl.net) |
| Date: | Tue, 13 Nov 2007 08:22:54 |
Hello all,
ever since we upgraded one of our servers to Windows 2003 server
one of my Delphi services no longer works properly. It used to
work flawlessly under WIndows 2000 server.
I have now located the problem but the underlying cause eludes me,
because I believe I have done nothing wrong.
In the service, one tThread performs an action inside its Execute
method and puts itself to sleep after every cycle:
Procedure tMythread.execute;
begin
while not terminated do
begin
Try
DoSomething;
Except end;
outputdebugstring('suspending');
Suspend;
Outputdebugstring('awake');
end;
Outputdebugstring('terminating');
end;
A timer in the main service is called every 10 minutes and
resumes the thread if it is not already running:
Procedure tMyservice.ontimer(sender:tobject);
begin
if mythread.suspended then
begin
outputdebugstring('thread was asleep-resuming');
mythread.resume;
end else outputdebugstring('thread is already running');
end;
The problem is, several times weekly, the system stops working.
Using Sysinternals' Debugview utility, I could verify that the thread's
last message was "suspending". So it must have suspended properly.
Yet the timer routine writes "thread is already running" into the log,
so the thread's property "suspended" must return false !!!!!
This just cannot be! Has "tthread.suspend" become unreliable
all of a sudden? Or am I overlooking something obvious?
--
Arthur Hoornweg
(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)