On 4 Dec, 22:32, Peter Bromberg [C# MVP]
<pbromb...@yaho o.NoSpamMaam.co mwrote:
having a service that interacts with the desktop is generally a very bad idea
anyway. The whole concept of a windows service is that it start with the OS -
before any real user has logged on. So if your service wants to do UI but
there is no desktop, what do you think will happen?
--Peter
"Inside every large program, there is a small program trying to get out."http://www.eggheadcafe .comhttp://petesbloggerama .blogspot.comht tp://www.blogmetafin der.com
Shure, on my openVMS all logging goes to textfiles but this was a
"normal" VB6 program from the start that I made to a service to get
rid of the fact that I had to be logged in.
Well, it (UI) works in my VB6 service (when i found ntsvc.ocx or
whatever it was called some years ago), UI just showing what happens
(have to check box "can interact with desktop")- connect DB, read
file, update DB and so on, and more important what not when an error
occures, but (obviusly) only when support personel loggs in (no
special handling in code for that).
and yes i write log files with the same info, it makes life easyer if
the server stops for any reason to rule out my program, but that hasnt
happend /yet/ - havent used eventlogger in my VB6 service, in the C#
service I write to the eventlogg instead - no (G)UI there.
Looking for guidelines about programming services (ready/prepared for
the future development of windows), yes my app is threaded, no
racecondition what I can see, should be threadsafe *but* can one ever
be safe from bugs, dont think so....
had a worry about not using thread.sleep(5) in my while(true) loop, it
gets a bit slower but the service shoul never be able to drain all cpu
from the server, connecting to a RFID reader and that *should* take
250-700ms depending on read method, but if it goes wrong then I do
error logging and sleep 5 sek, the 5 ms delay is for an event where I
dont see that it goes wrong and it dosn´t take 250-700ms, then the
program would be like (worst case)
no real code, just how the program could behave
while(true) // should never stop reading
{
if (false) // an error occured that I didn´t expect, the false is the
return value from the reading of RFID, someone stole its static IP
address for ex.
{
}
}
so I put in a sleep in the main while loop just to be safe..
//CY