PC Review


Reply
Thread Tools Rate Thread

Multiple Instances of App

 
 
=?Utf-8?B?RXJpYw==?=
Guest
Posts: n/a
 
      1st Nov 2007
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!
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      2nd Nov 2007
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!



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple instances of Excel (Multiple workbooks) Shane Microsoft Excel Setup 3 13th Nov 2009 06:07 PM
Multiple Instances for Multiple Monitors... Steve P Microsoft Excel Misc 4 19th Nov 2008 10:13 PM
Create list of unique instances from list of multiple Instances Dishon Microsoft Excel Worksheet Functions 0 3rd Mar 2008 11:46 AM
I want to create multiple instances of a form and then refer to individual instances. Savante Microsoft VB .NET 6 16th Apr 2007 09:31 AM
Multiple identities with multiple instances of Outlook =?Utf-8?B?V291dGVy?= Microsoft Outlook Installation 1 4th Oct 2004 11:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:05 PM.