Thanks, guys, then, what about this one?
What about it? Seems like the general idea would work, but why go to all
that trouble?
Though, as long as you're asking...
Why are you comparing the results from "GetExecutingAssembly()" with the
"current" process? Shouldn't that be the "process" process? And why use
GetExecutingAssembly() at all? Why not just compare the
"MainModule.FileName" properties for both processes (assuming you care
about that...if you really don't want two instances running, I'd suggest
you probably don't). And if you must use GetExecutingAssembly(), why do
the string replace in each loop iteration, rather than doing it once and
saving the result to use within the loop?
I suppose if there are good answers to the above questions, and you really
prefer to use that method rather than a named mutex, that's fine. But I
honestly don't see any advantage in the code you posted over the named
mutex, and in fact feel that the named mutex method is simpler, easier,
and just as reliable (and if you really only want to exclude multiple
instances executing from the same exact file location, you can use the
file location in the name of the mutex).
Pete