Thanks Angus, in fact I likewise I have a simple switch at startup to
decide whether I'm running in GUI or service mode, which I share below
as a way of saying thanks to the 'list' as I did not take on-board the
fact that the Svcmgr::Application-CreateForm call means the TService
class is
Hi,
I do it a little different but results are similar. I create my whole
application in a single TObject. So this object can run in a GUI as a
console application as a NTService.
For console application just App.Create; and run a message pump, for
NTService the same: create the object and
Should I be calling MessageLoop or ProcessMessages?
Neither, Delphi windows services are message driven just like Windows
applications.
Most of my windows services are actually dual GUI/service, with a simple GUI
that
does not require any interaction when run as a service. This makes testing
Should I be calling MessageLoop or ProcessMessages?
I now have a working (but horrible) solution:
TService creates a thread to perform the main processing
On the first event this thread creates a TSslWSocket (with
MultiThreaded=false) and calls Connect
At this point I must call
In a console app's thread, I make a valid connection, I call
SslWSocket-Send, followed by MessageLoop.
Once I receive OnDataSent message I call
SslWSocket-PostQuitMessage();
And the data is sent and the control returns to the thread -
perfect.
The second time I want to send data
In a console application the best practice (not only for TWSocket) is to
create a hidden window and an associated message pump. For the rest your
application is only a message loop. The program itself you can do in a
separate object just as it is a forms application. No need to call
In fact I am not exiting the thread but I am calling:
SslWSocket-PostQuitMessage();
to break out of the socket MessageLoop
In doing so this sets the SslWSocket Terminated to true
Don't call it then!
I thought PostQuitMessage was to break a thread, it posts WM_QUIT which is
generally
the
A MS-Windows service
I'm doing the data send in the main thread of the service (there are no
other threads)
If I don't call the WSocket-PostQuitMesage then the MessageLoop runs
for ever stopping my thread doing anything else. (If I don't call
WSocket-MessageLoop nothing happens at all)