Detecting already started app.

M

Markus Humm

Hello,

how can I detect whether my app. is already launched so that I can
prevent starting it a 2nd time?

Is it possible to bring that instance of my app. to front when I detect it?

I'm using VB.NET and CF 1.0

Greetings

Markus
 
M

Markus Humm

Paul said:
And what device/device type are you running it on? This happens
automatically on Pocket PC and Smart Phone devices. It's also been covered
before many times. You can search the newsgroup archives for this group via
this link:

http://groups.google.com/group/micr...tframework?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8
Okay I will search. It's a pocket pc and it doesn't happen
automatically! I already tried. The app. crashes then at a certain point
because it can't open the already open RS232 port.

Greetings

Markus
 
P

Paul G. Tobey [eMVP]

That's an extreme surprise. Post a short repro example program...

Paul T.
 
M

Markus Humm

Paul said:
That's an extreme surprise. Post a short repro example program...

I can't because today the problem couldn't be reproduced but I guess
that it's a thing where you can have some race conditions and therefore
can start the application twice!

Evidence:

1. no other app. used the COM-Port when the error occured some day ago,
only our own one.

2. the exception thrown by the application (2nd instance as it must be)
was that it can't open the COM-Port because it is already in use.

=> since only our own app. had the port open it must have been launched
2 times as it seems because when it has the port open it only closes it
when being closed.

Greetings

Markus
 
P

Paul G. Tobey [eMVP]

Or maybe some previous close of the port hadn't completed before you started
the app the second time. There are significantly more possibilities than
just that the second instance outran the first and I'd tend to believe
something other than a strange race condition. Of course, if you don't
believe that, you can create a global named mutex during startup of your
application and check to see if it already exists. If so, assume that the
reason is another instance of the program already running and exit...

Paul T.
 

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

Similar Threads


Top