|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Windows Service project and how to debugHi,
I created a Windows Service project, the installers and the setup project for the service. Now I have the service installed but once I start it up, it's taking 100% CPU and not doing anything. I tried attaching the visual studio debugger to the win service process but it's not stopping at any breakpoints. Does anyone have any idea about why it's taking the 100% CPU. And how can I debug and see what's going on? Thanks very much in advance!! Agnes Agnes,
Only you can find out truly what is going on. Here are some suggestions: First, start your service from within the Debugger and see if you can tell what is happening. If that doesn't work. Then start it the way that you just did, then open Task Manager, go to the Processes page, find your service, right-click on the service, in the context menu select Set Priority, reduce the priority of the service, THEN try to attach your debugger. Remember that the Windows OS uses preemptive multitasking so other applications (including Task Manager) should eventually get a chance to execute. You might have a tight forever loop that may not be setup the way you expected. Make sure that the installer has set all your initial values (ie. registry settings, config file values, etc...) Good luck, Kim Greenlee -- digipede - Many legs make light work. Grid computing for the real world. http://www.digipede.net http://krgreenlee.blogspot.net "Agnes" <agnesw@nospam.nospam> wrote in message Insert a 30 sec. thread sleep in your main() or OnStart(). That will give news:60FB015D-81A1-49C2-AC08-958F7340EF55@microsoft.com... > And how can I debug and see what's going on? you time to attach the debugger to it, then you can trace it before it hangs. -- Alan Agnes wrote:
Show quote > Hi, Hi Agnes,> > I created a Windows Service project, the installers and the setup project > for the service. Now I have the service installed but once I start it up, > it's taking 100% CPU and not doing anything. I tried attaching the visual > studio debugger to the win service process but it's not stopping at any > breakpoints. > > Does anyone have any idea about why it's taking the 100% CPU. > And how can I debug and see what's going on? > > Thanks very much in advance!! > > Agnes Debugging services can be a real pain. I normally structure my services as three projects: 1) a DLL which exposes a singleton class which has Start/Stop/Pause/Continue methods 2) a Windows Form application with buttons which hook up to the four methods 3) a Windows Service which hooks up to the four methods. So the meat of my service is in the DLL. When I'm debugging, I use the Windows Form application to run it. When it's released, the service uses it. Only problem with this method is that the environment isn't quite the same for the service, because when it's debugged it's running under my user account, and it can interact with the desktop, two things unlikely to be true when it's running normally. This hasn't been a problem for me. Damien |
|||||||||||||||||||||||