all groups > dotnet clr > april 2008 >
You're in the

dotnet clr

group:

Further to the Discussion


Further to the Discussion Sunny S
4/10/2008 1:41:01 AM
dotnet clr:
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
RE: Further to the Discussion Sunny S
4/10/2008 2:11:02 AM
Sorry, pressed the wrong button. The 'discussion' mentioned relates to my
question 'Relationship between Application.Exit() and AppDomain' posted on
the 27 of April 2008.

[quoted text, click to view]
RE: Further to the Discussion Sunny S
4/10/2008 4:38:00 AM
Hi Jeff,

Thanks very much for your reply. It adds to my understanding of what's going
on:) Actually, Willy Denoyette [MVP] has already answered my question on the
original thread (27.04.2008) and I take his answer as correct. I was only
confused by Microsoft's documentation stating that the call to
Windows.Forms.Application.Exit() 'Informs ALL message pumps that they must
terminate, and then closes ALL application windows after the messages have
been processed'. I understand from Willy's reply that this is true only for
the message pumps in the current domain and its 'child' domains and it
doesn't affect a message pump in the 'parent' domain. At least that's how it
looks in my experiments.

Regards,
SS


[quoted text, click to view]
RE: Further to the Discussion jetan@online.microsoft.com (
4/10/2008 11:09:53 AM
Hi Sunny,

Oh, it seems that you did not register the MSDN subscription account
correctly for the 'Relationship between Application.Exit() and AppDomain'
issue on 27 of April 2008, since we did not get it in the internal support
tool. Anyway, you have got it setup correctly in this post since we can see
it now.

Ok, let's come back to your questions. "System.Windows.Application class"
is a WPF class which is completely different from the
"System.Windows.Forms.Application class". "System.Windows.Application
class" is the .Net Winform concept class. You should not confuse and use
these two concepts together. Since you are writing the .Net Winform code,
you should always using the information of Winform not WPF:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.as
px

Winform "System.Windows.Forms.Application class" has nothing to do with
AppDomain concept. You can think of "System.Windows.Forms.Application" as
the message loop encapsulation unit of GUI application.

Application.Exit() only kills the "Application"(Message Loop), not the
entire AppDomain, so what you saw is expected.
http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.ex
it.aspx

Hope this makes sense to you.

Best regards,
Jeffrey Tan
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Further to the Discussion Sunny S
4/10/2008 11:13:01 AM
Jeff,

Actually, my understanding of Willy Denoyette's reply was incorrect. My
experiments showed that message pumps started in different AppDomains are
independent in the sense that killing one of the pumps with a call to
Application.Exit() doesn't affect the others whatsoever. For more details
please have a look at my posts to Jon Skeet of 10/APR/2008 on the
'Relationship between Application.Exit() and AppDomain' started on 4/4/8. I'd
RE: Further to the Discussion jetan@online.microsoft.com (
4/12/2008 8:30:25 AM
Hi Sunny,

Thanks for your feedback. I have reviewed your discussions with Willy and
provided a reply to you in that thread. Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button