Re: Run App only once
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:8hnv13pcuc9rofnjmdvsbbmpdfhbmj7vhn@4ax.com...
I said it should not be used in a multiple-instance situation. Not just
for detecting the
instance, but at all. Note that the race condition I describe can mean
that the second
instance is detected before the first instance has produced a window.
Therefore, there is
nothing to flash. Therefore, it is unreliable.
It is reliable, as your own words say:
---
After you read the section on Race Conditions you may see that this code has
a race condition. If the Mutex was created by instance 1, which is still
coming up (it hasn't created its main window yet), and instance 2 finds that
the Mutex already exists, it tries to find the window for Instance 1. But
since Instance 1 is not yet there, this code does not pop up the window for
Instance 1. But that's OK. Because Instance 1 has not yet created its
window, it will proceed to create its window successfully and pop up just
like you'd expect.
---
BTW, I told you before you needed to modify your essay to have the second
instance call AllowSetForegroundWindow() to ensure the first instance
succeeds in bringing it's window to the foreground on creation. I guess you
haven't had a chance to do that yet.
-- David