CeRunAppAtEvent / Mutex

  • Thread starter Thread starter Miguel
  • Start date Start date
M

Miguel

I am experiencing the following problem.
F.e.
I want to run an application on the wakeup event of the mobile device.
I only want one instance of the application running at the given time (
single process).
The application itself just shows something on the screen, which is not
relevant to the problem.
CeRunAppAtEvent seemed to solve the problem.
However at wakeup, a new instance of the application is started.
Is there an easy solution to overcome this (perhaps by mutex or event)
an how do I have to implement this feature?

Regards
 
Correct, the answer is with a mutex. At app startup check for the mutex, if
it's already taken you need to shut down the current instance and activate
the other. A thread in the app specifically waiting for such an event is a
good mechanism for this.

--
Chris Tacke
Co-founder
OpenNETCF.org
Are you using the SDF? Let's do a case study.
Email us at d c s @ o p e n n e t c f . c o m
http://www.opennetcf.org/donate
 
I'm rather new to mutex.
Could you provide a small example how to achieve this?
I'd be grateful

Regards
 
My application is not a graphical one
It's merely an application that does some stuff in the background

Will this work aswell, since you're working with FindWindow (and there
isn't)

Regards
 
This will work as well it doesn't matter what application you have. The
main part of the code is:

IntPtr evnt = CreateEvent(IntPtr.Zero, false, false, AppNamedEvent);
if (Marshal.GetLastWin32Error() != 0)
{
// one instance of application is run,
// do work
}
....

CloseHandle(evnt);
 
Back
Top