Application exit

  • Thread starter Thread starter Rafael Pivato
  • Start date Start date
R

Rafael Pivato

How can I force a Smart Device Windows Form application to exit.

I tried adding a menu click handler with the following:
Me.Close()
Application.Exit()

I wish to make the application exit when the user closes the form too (at
the X - minimizes I guess).


Thanks,
Rafael Pivato
 
Hi Rafael,

By default .NET Compact Framework-based applications "smart minimize" on the
Windows Mobile platform. Check out this FAQ item for information on how to
modify this behaviour:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx#4.3

cheers jonathan

--
Jonathan Wells
Product Manager
..NET Compact Framework
Check out the .NET Compact Framework FAQ at:
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided “AS IS” with no warranties, and confers no rights.
 
The preferred method is using this.Close(). I will be adding a FAQ item on
this but for now, here is some info on using Application.Exit:

Application.Exit is a hard exit like Win32's PostQuitMessage(). It's meant
to pop off all message pumps, unwind the callstack and return execution to
the system.

The correct way to shut down an app on Windows (Win32 or .NET) is to close
its main application window (i.e. Form.Close). Any window that's still
present after the main message pump ends needs to be manually closed. It's
good practice to clean up your windows by closing them before your app exits
by calling Form.Close or Form.Dispose, depending on the intended behavior

People need to remember that .NET's OnClosing() is the managed version of
Win32's WM_CLOSE and not WM_DESTROY.

Additionally, if you use form.Close(), your app will get a chance to clean
up stuff, close files, etc.. by handling a OnClosing or OnClosed event.
These events don't get called if you rip your app out w/ Application.Exit.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top