You have three choices, which correspond
to the values in the ShutdownMode enumeration.
No matter what shutdown method you choose, you can always use the Application.
Shutdown() method to end your application immediately. (Of course, when you call the
Shutdown() method, your application doesn??™t necessarily stop running right away. Calling
Application.Shutdown() causes the Application.Run() method to return immediately, but
there may be additional code that runs in the Main() method or responds to the
Application.Exit event.)
nNote When ShutdownMode is OnMainWindowClose and you close the main window, the Application
object will automatically close all the other windows before the Run() method returns. The same is true if you
call Application.Shutdown(). This is significant, because these windows may have event handling code that
fires when they are being closed.
Application Events
Initially, the Application.xaml.vb file doesn??™t contain any code. Although no code is required,
you can add code that handles application events. The Application class provides a small set
of useful events. Table 3-2 lists the most important ones. It leaves out the events that are used
solely for navigation applications (which are discussed in Chapter 9).
Table 3-2. Application Events
Name Description
Startup Occurs after the Application.
Pages:
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176