Re: NT Service Problem

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi,
Thanks all of you. I have fixed the problem for now.There are no exceptions
when I stop/pause the service

Pete, I will definitely take your advise and "rethink & rewrite" my service.
This is my first windows service, so need to read a lot before I rewrite it
again.

Hope to get help from you in future too.

"Pete Delgado" wrote:


"Susanna" <Susanna@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5FA89596-956E-40C1-AF75-E2A5EAE5B593@xxxxxxxxxxxxxxxx
You've got it right , the problem is with not terminating the threads.
I'll try doing a terminatethread on stop.

Also I dont know how to attach a debugger to NT Service, so used the log
files instead.

To debug I just clicked on the NT Service exe in the task manager and
clicked on debug option and it says "Access is denied". Is that how a
debugger is attached?

In Visual Studio 2005 you would use the Tools\Attach to Process menu item
and select your service executable from the process list. Make sure that
you check the box that allows you to view processes from all users. In
addition, unless your service is running under your account credentials, you
must be using an administrative account or one with the appropriate
privileges in order to debug the process.

Lastly, I looked at the code snippet that you have posted as well as your
general comments here and would like to suggest the following:

1. Rethink and rewrite your service. Based upon your statements here, your
architecture sounds flawed.
2. Use the ATL service classes to create your base service template code.
This allows you to concentrate on the functionality of your service rather
than the boilerplate code.
3. Make sure that you concentrate on resource allocation, usage and cleanup.
A service is intended to run *forever*. A resource leak will slowly starve
your system.
4. Do *not* use the TerminateThread.
5. Pick up a good book or two and *read* them. I suggest the following:

1. Developing Server Side Applications for Windows 2000
http://www.amazon.com/o/ASIN/0735607532
2. Programming Applications for Microsoft Windows
http://www.amazon.com/Programming-Applications-Microsoft-Windows-General/dp/1572319968/sr=1-8/qid=1158073793/ref=sr_1_8/102-1222395-3979355?ie=UTF8&s=books

I don't mean to make it sound as if I am denigrating your skill as a
developer, but just be aware that service application development requires
much greater knowledge and care than does "normal" application development
for reasons described in the Richter books.

-Pete



.



Relevant Pages

  • Re: My Migrations
    ... particular model with "Windows, Linux, or BeOS" they lose a million ... Exactly, DR-DOS was a superior product, it got to 15% market share. ... Gates foundation gives away millions of, say, AIDS drugs, made by the ...
    (comp.lang.cobol)
  • Re: Strange Characters When Viewing Outlook Express messages
    ... www.insideoe.com is considered the OE Bible in my circle, Pete. ... All development on OE (and Windows Mail in Vista, ... but do not understand the CP Regional and Language options settings. ... changed something with whatever they use to produce the emails. ...
    (microsoft.public.windowsxp.general)
  • Re: My Migrations
    ... On Oct 2, 6:33 pm, "Pete Dashwood" ... particular model with "Windows, Linux, or BeOS" they lose a million ... Exactly, DR-DOS was a superior product, it got to 15% market share. ... first thing you noticed after Cobol. ...
    (comp.lang.cobol)
  • Re: 100% Linux - Is it possible?
    ... >Pete Choppin wrote: ... >> considering going completely 100% Linux and dumping my Windows ... > consider that partition as close to zero cost insurance. ...
    (Fedora)
  • Re: Cant Delete Temp Internet Files
    ... my setting to automatically delete temp files when closing ... browser does not work and clicking on the "Tools>Internet Options>Delete ... > Pete wrote: ... > Windows - Internet Explorer since 2003 ...
    (microsoft.public.windows.inetexplorer.ie6.browser)