Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / November 2007

Tip: Looking for answers? Try searching our database.

Multiple Instances of App

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eric - 01 Nov 2007 16:32 GMT
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!
<ctacke/> - 02 Nov 2007 05:13 GMT
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).

Signature

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

>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.
[quoted text clipped - 35 lines]
>
> Any insights or assistance would be greatly appreciated!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.