I am working in a service that watches the file system for a modification/addition/removal of anything inside a folder. As I started to implement it, I'd met this property, inside the ServiceBase
class, ServiceBase.Serv开发者_开发百科iceHandle
.
thanks
The ServiceBase.ServiceHandle
is the system handle used to update the service's status in the Services control panel. It is the same handle returned by the Win32 RegisterServiceCtrlHandler
and RegisterServiceCtrlHandlerEx
functions.
All services have the responsibility of updating their status. In unmanaged services, such as those created in C++, this was the responsibility of the developer. You'd pass the handle and the updated status (e.g., START_PENDING, RUNNING, STOPPED) as input to the Win32 SetServiceStatus
function when the status changed.
Even in managed services, such as those created with C#, the developer is still responsible for updating the status; it's just that the ServiceBase
class performs all of the status updates for you.
In short, I would say that this handle is completely unnecessary for managed services that inherit from ServiceBase.
精彩评论