Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 pause window service does not work properly

Author  Topic 

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-04-08 : 20:54:57
Hi, I have written a pause service function to pause my window service when it hits exception. When there is exception occur, my window service is in Pause state, but it does not really stop running the window service (as I found that the service is still running all the functions and writing into my event log). Any idea?? I do use threading timer in the service, may it be the problem?


Public Function PauseService() As Boolean
Try
'Dim controller As ServiceController = New ServiceController("ServiceMaintenance", gstrActiveSvr)
Dim controller As ServiceController = New ServiceController(gstrServiceName, gstrServerName)
If controller.CanPauseAndContinue Then
controller.Pause()
controller.WaitForStatus(ServiceControllerStatus.Paused)
Return True
End If
Return False
Catch ex As Exception
Return False
End Try
End Function

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-04-08 : 22:32:56
This isn't really an ASP.NET question.

if you are implementing a (pausable) windows service in managed code, you should inherit from System.ServiceProcess.ServiceBase and simply override the OnPause() and OnContinue() methods.




elsasoft.org
Go to Top of Page

juicyapple
Posting Yak Master

176 Posts

Posted - 2008-04-09 : 05:53:50
quote:
Originally posted by jezemine

This isn't really an ASP.NET question.

if you are implementing a (pausable) windows service in managed code, you should inherit from System.ServiceProcess.ServiceBase and simply override the OnPause() and OnContinue() methods.




elsasoft.org



Oops, I do not aware that I have posted to wrong place.

For my case, I have already can pause the service, as I check from services, it shows status paused. I thought all the functions should be paused, but at the end I found that it still running at backend, and keeps updating the event log.
Go to Top of Page
   

- Advertisement -