Hi;
I'd like to understand, if you can spend a little more time, the
difference between this method and CreateMutex (named). TIA.
"Sergey Bogdanov" <
[email protected]> ha scritto nel messaggio
Yep, carefully see the example [1]:- CreateEvent is:
[DllImport("coredll.dll", EntryPoint="CreateEvent", SetLastError =
true)]
private static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool
bManualReset, bool bInitialState, string lpName);
[1]
http://www.sergeybogdanov.com/Samples/SPSingleInstance.zip
--
Sergey Bogdanov
http://www.sergeybogdanov.com
Saverio Tedeschi wrote:
Hi Sergey;
CreateEvent is not supported in my version of CF, as only GetEvents and
GetProperties are supported as methods of
System.ComponentModel.TypeDescriptor. Did I take the wrong way or am I
overlooking something? TIA.
"Sergey Bogdanov" <
[email protected]> ha scritto nel messaggio
The example demonstrates how to use named event and does not depend
from the main form:
IntPtr evnt = CreateEvent(IntPtr.Zero, false, false, AppNamedEvent);
if (Marshal.GetLastWin32Error() != 0)
{
// one instance of application is run, activate it
IntPtr hwnd = FindWindow(null, "Form1");
if (hwnd != IntPtr.Zero)
{
SetForegroundWindow(hwnd);
}
return;
}
As you can see it will activate the main form if it exists and exit
all the same.
--
Sergey Bogdanov
http://www.sergeybogdanov.com
Saverio Tedeschi wrote:
Thank you Sergey, for your reply.
The problem is, referees try to call program twice (or three times,
or four) before it can display a form, for it needs to do some
housekeeping. I immediately spawn a secondary task to display splash
screen, but it has not the name of the main form, and more, it closes
by itself after 10 seconds (housekeeping takes abot 12 secs on a
200MHz XScale processor, or on a 400 forced to 200 for
battery-lasting purposes). I appreciate your clue anyway.
"Sergey Bogdanov" <
[email protected]> ha scritto nel
messaggio
Here is an example how to create a named event to accomplish the
single instance behaviour for your application in SmartPhone. This
code snippet should work for PPC either:
http://www.sergeybogdanov.com/Samples/SPSingleInstance.zip
--
Sergey Bogdanov
http://www.sergeybogdanov.com
Saverio Tedeschi wrote:
Thank you, Chris, for your reply.
Useless to say, I'm moving my first steps into inter-program and
inter-task syncronization, so pls forgive me if I'm bothering you.
However, I can't find how2 create a named mutex in VS 2003 (CF 1.0
SP2), as there's only an "Already owned" parameter in New function.
Should I create a Win32-wrapper? Where can I find C# or VB
declaration for PPC2002/2003 targets? TIA
"Chris Tacke, eMVP" <
[email protected]> ha scritto nel
messaggio
A semaphore is not something useful in this case. A mutex is,
hence the recommendation.
--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
Hi Chris,
thank you 4 your reply. What about CreateSemaphore function?
Easier, tricker, harder? TIA
"<ctacke/>" <ctacke_AT_OpenNETCF_com> ha scritto nel messaggio
You need to grab a named mutex at app startup. If it already
exists, the app is already running so exit. Search the archives
for CreateMutex and/or single instance.
-Chris
Hi all gurus,
forgive me if I'm bothering you. My .NET CF app is designoed to
be executed once in target PDAs. However, in customers' hands
(actually, refereees) it seems they are able to spawn app more
than once, as I receive errors on table locking and replying
"OK" the app opens the table, while the design is to loop in
opening retries, and a certain numbers of little (?)
malfunctioning routines like this one. Even if this (most time)
does not lock the execution, there error messages are annoying
and, the most important thing, confusing. I guess that in the
time the app performs some inizialization, users are apple to
launch it a couple of times, tapping on HW button associated.
How can I avoid this (kkep in mind that for a couple of seconds
nothing appear on PDA's screen. Can some1 point me to the right
direction? TIA!