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
I guess is the same instance. You can do a quick test adding a static field in the class to keep track of the reference to the object used in the OnStart and comparing it to the instance of the OnStop.
private static CometService instance = null;
protected override void OnStart(...)
{
instance = this;
...
}
protected override void OnStop()
{
object.ReferenceEquals(this, instance);
...
}