Re: Relationship between Application.Exit() and AppDomain



"Ben Voigt [C++ MVP]" <rbv@xxxxxxxxxxxxx> wrote in message news:uOlihGYmIHA.484@xxxxxxxxxxxxxxxxxxxxxxx
Willy Denoyette [MVP] wrote:
"Barry Kelly" <barry.j.kelly@xxxxxxxxx> wrote in message
news:4djkv39krr67nr7f3fjttfi86581in3gpm@xxxxxxxxxx
Willy Denoyette [MVP] wrote:

"Barry Kelly" <barry.j.kelly@xxxxxxxxx> wrote:

Willy Denoyette [MVP] wrote:

Application.Exit() is a Forms API,

That is true.

Well here you are calling PostQuitMessage which doesn't really do
what it's
supposed to do

PostQuitMessage posts WM_QUIT to the current thread's message queue.
This is no different in a WPF application than in any other Windows
application. WM_QUIT causes GetMessage to return 0.


Well, It doesn't post a WM_QUIT message to the UI's thread queue when
run on Vista (both RTM and SP1), of course it does post WM_QUIT when
called in a Windows.Forms based application (or any non managed
windows app.).

Barry has this one exactly right. PostQuitMessage is a Win32 function, it couldn't care less whether your app is WPF or WinForms or MFC or whatever. It posts WM_QUIT and returns.

I don't know how you can get any clearer than this:

http://msdn2.microsoft.com/en-us/library/ms644945(VS.85).aspx
"The PostQuitMessage function posts a WM_QUIT message to the thread's message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future."



The docs are clear, but I'm afraid they are missing some additional remarks when run on Vista (don't know what happens on XP SP2 and SP3).
Please don't point to the docs to prove I'm wrong, use some debugging tools and correct me if you notice the *documented* behavior.
Running SpyXX [1] doesn't reveal any WM_QUIT message for a WPF enabled application (say the sample posted by Barry), it does (as expected) when called from any other type of application (managed Forms, and native MFC and Win32).
If you can't get Spyxx (from VS2008) to work for you, or if you don't fully trust what SPxx reveals(like I do), you can always run the app in the debugger (say Windbg), set a breakpoint on GetMessageW and inspect the MSG struct returned (there are quite a lot of them) when you call the API, you won't see any WM_QUIT message (at least I don't).


Willy.

On Vista32 SP1 and Vista64 SP1 and WS2008, all running the same v3.5 Framework bits.

.



Relevant Pages

  • Re: Relationship between Application.Exit() and AppDomain
    ... it couldn't care less whether your app is WPF or WinForms ... message queue and returns immediately; ... You really should break on PostMessage and PostThreadMessage, because it's entirely possible that PostQuitMessage did exactly what the documentation described, but the .NET method triggered ending the message loop so GetMessage was never called. ... That's the portion that needs to coordinate with the DWM composition, that's the part that handles PQM when called from a WPF application running on Vista with DWM enabled. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: WPF--a threat to WinForms?
    ... In my opinon Enterprise desktop applications already ... see WPF having a lot to offer over WinForms to most enterprise desktop ... Windows Presentation Foundation (WPF) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: VB.NET 2008 not backward compatable?
    ... Multiple applications sharing the same DLL can quickly turn hellish if you make alterations, even if they don't break binary compatibility. ... How To Build and Service Isolated Applications and Side-by-Side Assemblies for Windows XP ... Unfortunately Microsoft doesn't use WPF for their applications at the moment and thus there are still some huge problems like faulty ClearType support, ... I didn't criticize that they rebuilt the existing Win32 controls, I criticized that the remake had annoying limitations compared to the Win32 controls. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: WPF v Windows Forms
    ... there is no real need for 3D graphics and animations, ... WPF is at v1.0 and Vista desktop penetration will take a while. ... WPF is Microsoft's unified presentation subsystem for Windows and is ... Letting WPF applications use these existing controls can make sense in some ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Question About Converting WinFormControls To XAML
    ... WPF is Microsoft's unified presentation subsystem for Windows and is ... Windows Presentation Foundation provides a unified approach to user ... Letting WPF applications use these existing controls can make sense in some ...
    (microsoft.public.dotnet.framework.windowsforms.controls)

Loading