Game Development Reference
In-Depth Information
chapter 18
Ensuring a Single
Instance of an Application
Never allow the same bug to bite you twice.
Steve Maguire
With most modern operating systems, multiple instances or processes of an appli-
cation can be launched, each with its own internal state and memory. Some tools
are not affected by multiple instances being launched, but other tools are. Imagine
a tool that, when launched, creates a network socket and binds it to a specific port
through which to receive data. If a second instance of that tool were launched, the
initialization would fail because the network port would already be in use. As
another example, look at Adobe Photoshop or any other fully featured image edit-
ing suite. How frustrating do you think it would be if, every time you double-clicked
an image on your desktop, a new instance of Adobe Photoshop would launch?
When a file associated with a specific application is launched from Windows
Explorer, the file name is not passed to a current running process if there is one.
The application that handles the file is determined and a new instance is launched
with the file name as a parameter.
A solution to this problem would be a system that could determine whether there
are any running instances of a particular application, redirect launch parameters
to the running instance, and abort the launching of any additional instances.
183
Search Nedrilad ::




Custom Search