So I\'ve got a Windows service written in c#. The service class derives from ServiceBase
, and starting and stopping the service calls instance methods OnStart
If you look in the Program.cs
class, you'll see code like the following:
private static void Main()
{
ServiceBase.Run(new ServiceBase[]
{
new CometService()
});
}
That is, the instance is created by code within your own project. It's that one instance that all Service Manager calls (including OnStart
and OnStop
) are made against.