We want our phones to be much
like our other computers. We want to have a lot of applications
available. We want to start up a particular application as soon as we
conceive a need for it. While that application is running, we want it to
be as fast as possible and have access to unlimited resources. But we
want this application to coexist with other running applications because
we want to be able to jump among multiple applications running on the
machine.
Arbitrarily jumping
among multiple running applications is somewhat impractical on the
phone. It would require some kind of display showing all the currently
running applications, much like the Windows taskbar. Either this taskbar
would have to be constantly visible—taking valuable screen space away
from the active applications—or a special button or command would need
to be assigned to display the taskbar or task list.
Instead, Windows Phone 7
manages multiple active applications by implementing a stack. In a
sense, this application stack extends the page stack within a single
Silverlight program. You can think of the phone as an old-fashioned web browser with no
tab feature and no Forward button. But it does have a Back button and it
also has a Start button, which brings you to the Start screen and
allows you to launch a new program.
Suppose you choose to launch a
program called Analyze. You work a little with Analyze and then decide
you’re finished. You press the Back button. The Analyze program is
terminated and you’re back at the Start screen. That’s the simple
scenario.
Later you decide you need to
run Analyze again. While you’re using Analyze, you need to check
something on the Web. You press the Start button to get to the Start
screen and select Internet Explorer. While you’re browsing, you remember
you haven’t played any games recently. You press the Start button,
select Backgammon and play a little of that. While playing Backgammon,
you wonder about the odds of a particular move, so you press the Start
button again and run Calc. Then you feel guilty about not doing any
work, so you press the Start button again and run Draft.
Draft is a Silverlight
program with multiple pages. From the main page, you navigate to several
other pages.
Now start pressing the Back
button. You go backwards through all the pages in the page stack of the Draft,
then Draft is terminated as you go back to Calc. Calc still displays the
remnants of your work, and Calc is terminated as you go back to
Backgammon, which shows a game in progress, and Backgammon is terminated
as you go back to Internet Explorer, and again you go backwards through
any Web pages you may have navigated through, and IE is terminated as
you go back to Analyze, and Analyze is terminated as you go back to the
Start screen. The stack is now empty.
This type of navigation
is a good compromise for small devices, and it’s consistent with users’
experiences in web browsing. The stack is conceptually very simple: The
Start button pushes the current application on the stack so a new
application can be run; the Back button terminates the current
application and pops one off the top of the stack.
However, the limited resources
of the phone convinced the Windows Phone 7 developers that applications
on the stack should have as minimum a footprint as possible. For this
reason, an application put on the stack does not continue plugging away
at work. It’s not even put into a suspended state of some sort.
Something more severe than that happens. The process is actually
terminated. When this terminated program comes off the stack, it is then
re-executed from scratch.
This is tombstoning. The application is killed but then allowed to come
back to life.
You’ve probably seen enough
movies to know that re-animating a corpse can be a very scary
proposition. Almost always the hideous thing that arises out of the
filthy grave is not the clean and manicured loved one who went in.
The trick here is to
persuade the disinterred program to look and feel much the same as when
it was last alive and the user interacted with it. This process is a
collaboration between you and Windows Phone 7. The phone gives you the
tools (events and a place to put some data); your job is to use the
tools to restore your program to a presentable state. Ideally the user
should have no idea that it’s a completely new process.
For some applications,
resurrection doesn’t have to be 100% successful. We all have experience
with navigating
among Web pages to know what’s acceptable and what’s not.
For example, suppose you visit a
long Web page, and
you scroll down a ways, then you navigate to another page. When you go
back to the original page, it’s not too upsetting if it’s lost your
place and you’re back at the top of the page.
On the other hand, if
you’ve just spent 10 minutes filling out a large form, you definitely do
not want to see
all your work gone after another page tells you that you’ve made one
tiny error.
Let’s nail down some
terminology that’s consistent with some events I’ll discuss later:
When an application is
run from the Start screen, it is said to be launched.
When an application is
terminated as a result of the Back button, it is closed.
When
the program is
running and the user presses the Start button, the program is said to be
deactivated,
even though it really is quite dead. This is the tombstoned state.
When a program comes out of tombstoning as the user navigates back to it, it is
said to be activated, even though it’s really starting up from scratch.