Appdomains and named events

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dilip

    Appdomains and named events

    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?
  • Peter Duniho

    #2
    Re: Appdomains and named events

    On Sat, 23 Feb 2008 20:35:58 -0800, Dilip <rdilipk@lycos. comwrote:
    [...]
    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? [...]
    I don't know of a way to find out who set the event, though that doesn't
    mean there isn't one.

    But, can you just use a different named event for the in-process signaling
    than for the cross-process signaling? Presumably you can't change the
    name used for cross-process signaling, but why not create a different
    named event for the internal signaling and use that?

    Then you just do the appropriate thing according to which event was
    actually signaled?

    Pete

    Comment

    Working...