Tuesday, 27 August 2013

Can Process.HasExited be true for the current process?

Can Process.HasExited be true for the current process?

I have recently seen some production code to the effect of:
if (Process.GetCurrentProcess().HasExited)
{
// do something
}
Does this make any sense? Intuitively, if the process has exited then no
code can be running inside it.
If not, what would be a good way to tell if the current process is
terminating?
If it can be of any relevance, the use case for this was to avoid
displaying assertions like objects not disposed when the process is being
killed.

No comments:

Post a Comment