Beruflich Dokumente
Kultur Dokumente
SCENARIO
During these practical sessions you will take the role of a developer creating
applications for the Windows Phone platform.
After completing this lab you will be able to:
Create custom icons for Silverlight applications
Understand how an application is tombstoned and the way that
tombstone events are generated and objects constructed
Estimated lesson time: 35 minutes
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
System.Diagnostics.Debug.WriteLine("Closing");
}
15. Select the Windows Phone 7 Emulator as the deployment target and
click Debug>Start Debugging to run the program.
16. Select Debug>Windows>Output to make sure that the Output
window is visible. This window will show you the output from the
diagnostic messages you added above. The last line in the window
should be the message Launching. This was produced by a call of the
Launching method.
17. Ensure that you can still see the Output window and move the
emulator onto the screen.
Investigating Tombstoning
Now we are going to “tombstone” our application and resume it in the
emulator.
1. Click Debug>Start Debugging to run the program in the emulator.
2. Move the emulator so that you can see both the emulator and the
Output window in Visual Studio.
3. Click the Start (the middle) button on the Windows Phone emulator.
4. You should see the content of the Output window change, with a
Deactivated message appearing directly below the Launching one,
followed by further messages about threads that are being stopped.
5. The Windows Phone should now be at is Start page. This will just
contain a large tile for the Internet Explorer application.
6. Click the tile in the Windows Phone emulator to start Internet
Explorer. This will open the browser and display a start web page.
7. Click the Back key. This will return you to the Start page on the
Windows Phone emulator.
8. Click the Back key again. This will return to our application. You will
see some messages added the Output window in Visual Studio and
the emulator will display the application page again. If you scroll back
through the messages in the output window you will find an
Activated message.
The application was “tombstoned” when we pressed Start and then
resumed when we pressed Back.
5. Run the application. You will see messages in the Output window
showing that the App class was constructed, then the Launching
message was produced and finally the MainPage was constructed.
6. This means that the launching message was produced before the
page was constructed.
7. Now press the Start button on the emulator. The program is
tombstoned and the Deactivated message is produced.
8. The emulator should now be at the Start screen.
9. Press the Back button on the emulator to resume the application.
10. The application will restart and Visual Studio will show messages
from the constructors for the classes as brand new instances are
created. In between the construction you should see the Activated
message that indicates that this application has been resumed from a
tombstone.
In this session you have improved your understanding of what happens
when applications are started and stopped on Windows phone. You have
also discovered how to add instrumentation to your application and view
messages in the Output window.