Do I need to check if my application has been launched?

G

Guest

Hi Guys.

I am wandering that if I click my application more that two times.
or, it has been started,but not run on the foreground, and user go to
file exploer to launche it again.

What will happen?
It will be called more than two times, or Windows MW OS will monitor it.
and it will be only called one time. after it has been started, when user
click APP
ICON, it will brings it to foreground.

I have tried some app, Sometimes it is brough to foreground,sometimes it
runs two times.

I do not know the reason. What I design is to launch only one time unless
user exit and then start it.

Thanks
 
P

Paul G. Tobey [eMVP]

Please confirm what devices you're talking about. .NET CF does the right,
but different, things for both generic Windows CE and Windows Mobile. On
CE, multiple copies should always be run. On WM, only one copy should ever
be run.

Paul T.
 
G

Guest

There's the problem with CF on WM (IMHO). The CLR acquires a mutex when an
app is run, but that mutex is acquired pretty late in the startup process.
So if the app is fully up and you try to launch another instance, the
existing instance gets activated. However if the app isn't fully up
(double-tap the icon for example) then you can often get the second instance
into the loader before the first has acquired the mutex. It's almost like
it does something like this:

AppStart();
CheckSingletonMutex();
LoadAppIntoCLR();
AcquireSingletonMutex();

For this reason you should still use your own mutex in your app startup,
even on WM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top