S
sidd
Hi all,
how do i exit out(unload) of a windows service in case of an error.
so i have a code block as follows
try
{
}
catch(exception ex)
{
//log to event log
Application.exit();
}
i can do the above in a winforms application but can i do the same in
a windows service?i understand that i can add the required namespace
in service class and call Application.Exit() ...but is this the right
way to exit from a windows service?
2)assuming application.exit is okay to use in windows service...are
there any events which would be called before windows service exits?
in other words will it fire OnStop or any other event?
3)also when you call application.exit (or even when you stop windows
service form service explorer)..
would it just stop the service
OR
does it also unload the windows service class from memory....in other
words what would happen to a static variable declared in side a
windows service class?
would it get reinitialized to original value ..next time the service
is started? i am asking this because i think the constructor of the
class does not fire each time you restart the class which would mean
that class may not be unloaded from memory...so i am not sure how
static would work?
thanks
siddharth
how do i exit out(unload) of a windows service in case of an error.
so i have a code block as follows
try
{
}
catch(exception ex)
{
//log to event log
Application.exit();
}
i can do the above in a winforms application but can i do the same in
a windows service?i understand that i can add the required namespace
in service class and call Application.Exit() ...but is this the right
way to exit from a windows service?
2)assuming application.exit is okay to use in windows service...are
there any events which would be called before windows service exits?
in other words will it fire OnStop or any other event?
3)also when you call application.exit (or even when you stop windows
service form service explorer)..
would it just stop the service
OR
does it also unload the windows service class from memory....in other
words what would happen to a static variable declared in side a
windows service class?
would it get reinitialized to original value ..next time the service
is started? i am asking this because i think the constructor of the
class does not fire each time you restart the class which would mean
that class may not be unloaded from memory...so i am not sure how
static would work?
thanks
siddharth