Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / April 2008

Tip: Looking for answers? Try searching our database.

Further to the Discussion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sunny S - 10 Apr 2008 09:41 GMT
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 - 10 Apr 2008 10:11 GMT
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.

> Gentlemen, thank you very much for an interesting discussion, from which I
> learned a lot, but I feel I had to be more specific.
[quoted text clipped - 23 lines]
>
> SS
Jeffrey Tan[MSFT] - 10 Apr 2008 12:09 GMT
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.
Sunny S - 10 Apr 2008 12:38 GMT
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

> Hi Sunny,
>
[quoted text clipped - 52 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
Sunny S - 10 Apr 2008 19:13 GMT
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
appreciate if you could comment on the issue.
Jeffrey Tan[MSFT] - 12 Apr 2008 09:30 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.