Prev | Current Page 175 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

The basic technique is to check whether another instance of your application
is already running when the Application.Startup event fires. The simplest way to do this
is to use a systemwide mutex (a synchronization object provided by the operating system that
allows for interprocess communication). This approach is simple but limited??”most significantly,
there??™s no way for the new instance of an application to communicate with the existing
instance. This is a problem in a document-based application, because the new instance may
need to tell the existing instance to open a specific document, if it??™s passed on the command
line. (For example, when you double-click a .doc file in Windows Explorer and Word is already
running, you expect Word to load the requested file.) This communication is more complex,
and it??™s usually performed through remoting or Windows Communication Foundation (WCF).
A proper implementation needs to include a way to discover the remoting server and use it to
transfer command-line arguments.
But the simplest approach, and the one that??™s currently recommended by the WPF team,
is to use the built-in support that??™s provided in Windows Forms and tailored to Visual Basic
applications. This approach handles the messy plumbing behind the scenes.
So, how can you use a feature that??™s designed for Windows Forms to manage a WPF application?
Essentially, the old-style application class acts as a wrapper for your WPF application
class.


Pages:
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187