Word Mobile is not a managed app, so they don't have this "feature". What
you need is to override the terrible behavior of "enforced" singleton apps
(which doesn't always work anyway). In the app you need to launch a
listener thread at startup and also create a named mutex. If the mutex
exists, you know another instance is running, so you use IPC to send your
command line to the thread in the already runnign instance which in turn
reacts (by loading the new file or whatever).
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
"Eric" <(E-Mail Removed)> wrote in message
news:0B3A5471-C066-45A9-8AE5-(E-Mail Removed)...
>I am developing an application for Windows Mobile 6 in C#, and I'm having
> trouble implementing what seems to be some fairly typical behavior.
>
> When I'm in Word Mobile and switch to File Explorer and select a different
> document, magically Word Mobile switches "context" and shows the new
> document. I need to better understand the "magic."
>
> Here is my current understanding. Windows Mobile will only allow one
> instance of an app at a time. It enforces this policy at the time of
> window
> class registration. When the second app instance tries to register a
> window
> class, Windows Mobile says "Oh no you don't -- you are already running,"
> shuts down the second instance and activates the first instance instead.
>
> So in the Word Mobile case, the second instance somehow knows that another
> instance is running, and prior to any window class registration uses some
> IPC
> mechanism to tell the first instance to switch its context (document),
> then
> exits.
>
> Can anyone confirm my understanding of this?
>
> Assuming my understanding is close to the mark, I have some questions:
>
> 1. What is the best means for determining that you are not the first
> instance of your application?
>
> 2. What is the best means of communicating the new context to the first
> instance? (Mailslot? Memory mapped file?)
>
> 3. Can this be done at all in a managed application? According to my
> experiments, the C# main never gets executed in the second instance,
> leading
> me to believe that the CLR does window class registration before calling
> main. Can anyone confirm this?
>
> Any insights or assistance would be greatly appreciated!