Checking for other running CF applications

A

Andrew Mac

I've had success in using the various "CreateMutex" procs to stop
multiple instances of the same application but I've been unable to
find some code to check for other running named processes. In eVB I
managed to just use Mutex for that as well but it's not triggering any
code I write to trap it in VB .Net on the compact framework. Any
ideas, comments, samples would be welcome. These other applications
may be multi-form apps.

Thanks!
 
P

Paul G. Tobey [eMVP]

Mutexes work the same no matter what environment your code is written in.
What, exactly, are you trying to achieve? You want to prevent application B
from running when application A is already running?

Paul T.
 
A

Andrew Mc

Hi,

Yep. I want to stop application B from running when application a is
active. I can use the mutex code to check for multiple instances of a
single app but I've been unable to get it to work for a different app in
compact framework for some reason. Do you have any sample code you know
works? This would be appreciated.

Thanks
 
J

Jon Skeet [C# MVP]

Andrew Mc said:
Yep. I want to stop application B from running when application a is
active. I can use the mutex code to check for multiple instances of a
single app but I've been unable to get it to work for a different app in
compact framework for some reason. Do you have any sample code you know
works? This would be appreciated.

What does your mutex code look like? So long as you use the same mutex
name in both applications, it should work fine.

(The compact framework stops multiple instances of the same app from
starting anyway.)
 
D

Daniel Moth

(The compact framework stops multiple instances of the same app from
starting anyway.)

Just to clarify... the statement above is only true for Pocket PC devices...

Cheers
Daniel
 
P

Paul G. Tobey [eMVP]

As Jon said, the code should be exactly the same for either case. If you
want app B to check for app A before it runs, have app A create a named
mutex when it starts. When app B starts, check for the existence of the
mutex. If it's there, exit app B immediately. When app A exits, it should
close the mutex handle it got from CreateMutex, of course.

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

Top