S
Smithers
I'm writing a new Windows Service. During the OnStart event procedure I
initialize a few things. If initialization fails, then I do not want for the
service to start.
What I currently have is something like this:
if (All initialization tasks succeeded)
{
// log the fact that initialization succeded
// do some other stuff
}
else
{
// log the fact that initialization failed
this.Stop();
}
I'm not sure about my use of "this.Stop()" above. Does it even make sense to
put that in the OnStart event procedure...? has the service actually started
at this point? Is there a better way to accomplish the objective of "not
starting" the service when initialization tasks fail during the OnStart
event procedure?
Thanks!
initialize a few things. If initialization fails, then I do not want for the
service to start.
What I currently have is something like this:
if (All initialization tasks succeeded)
{
// log the fact that initialization succeded
// do some other stuff
}
else
{
// log the fact that initialization failed
this.Stop();
}
I'm not sure about my use of "this.Stop()" above. Does it even make sense to
put that in the OnStart event procedure...? has the service actually started
at this point? Is there a better way to accomplish the objective of "not
starting" the service when initialization tasks fail during the OnStart
event procedure?
Thanks!