RE: Relationship between Application.Exit() and AppDomain



Keep hitting wrong buttons, sorry...

Gentlemen, thank you very much for an interesting discussion, from which I
learned a lot, but I feel I had to be more specific.

1. Let’s say I’ve started a SimpleWinForm application. I presume that means
starting a message loop.

2. From within that application I create an AppDomain in which I create a
new thread on which I call Application.Run(new SomeOtherWinForm()). See, for
example, Jon Skeet’s code above except that the code should be running on a
dedicated thread in a separate AppDomain.

Microsoft documentation says that Application.Exit() method ‘Informs ALL
message pumps that they must terminate, and then closes all application
windows after the messages have been processed’.

From the above I would conclude that upon calling Application.Exit() both
SomeOtherWinForm and SimpleWinForm should close and the whole thing should
terminate. Experiments show that this is not the case – only SomeOtherWinForm
closes.

Again, Microsoft documentation for System.Windows.Application (not
System.Windows.Forms.Application!) says that there is only one instance of
Application object per AppDomain. It looks as if the same relationship is
true for System.Windows.Forms.Application objects and AppDomains, because
this would explain the above behaviour, but I wasn’t sure.

SS


"Sunny S" wrote:

Hi,

Does Application.Exit() apply only to the AppDomain in which it is called?
Is it the same as in WPF – a single Application object per AppDomain?
Generally speaking, what is the relationship between an Application object
and AppDomain objects?

Regards,

Sunny S.
.


Loading