I have a peculiar problem that I am not sure how to solve.
I have a C# application that has 2 appdomains. The default appdomain
just exposes a remoting end point that external applications can call
into if they want to re-start code executing in the other appdomain.
The main thread of the other appdomain creates a named event and waits
on it (while the actual code is executing in other threads). So when
the remoting end point recieves a call to restart the other appdomain,
I just set the named event to signaled state so that the main thread
in the other appdomain is released and the appdomain subsequently
shuts down.
Now.. for reasons we can't do anything about, other external
applications can also shut down that piece of code by directly opening
the named event and setting it.
My question is, is there a way I can distinguish (from inside the C#
application), whether the other appdomain is shut down as a result of
a call received from the remoting endpoint or externally by another
application?
The reason I am asking is, the other appdomain will be relaunched if
it was shut down as a result of a request received from the remoting
endpoint -- if it was shut down as a result of some external
application directly triggering the named event then I want the entire
process to simply shut down, period.
Am I making sense?