Re: How to allow a specific number of Instances of my app?
- From: "Ralph" <nt_consulting64@xxxxxxxxx>
- Date: Sun, 29 Oct 2006 21:52:31 -0600
"expvb" <nobody@xxxxxxx> wrote in message
news:u7G6aJ8%23GHA.4712@xxxxxxxxxxxxxxxxxxxxxxx
<snipped>
MSDN
I agree with you that if an application crashes, all bets are off since
documentation is usually not clear about this, but in this case it seemsobject
that the mutex is closed when the application crashes. The reason I think
that this is the case is that VB6 itself creates a mutex or semaphore
with the full EXE name, which is used to provide App.PrevInstance
functionality. One can see the mutex/semaphore created by VB6 by using
Process Explorer:
http://www.sysinternals.com/Utilities/ProcessExplorer.html
In one test, it showed the following object:
Type: Semaphore
Name: \BaseNamedObjects\C:?TEST?PROJECT1.EXE
If the mutex/semaphore is not closed when the application crashes, then
crashed VB6 apps cannot be run without restarting the computer.
There is a bit of hesitation as it has been years since I piddled around
with the guts of VB, so I may be mistaken...
I doubt that VB implements App.PrevInstance using a Mutex/Semaphore as it is
so easily fooled. That's why the 'work-around', a Mutex, is often suggested
as a more reliable mechanism.
Also I have through-out my wobbly career created apps which crashed and
could not be restarted without re-booting the system. Now whether or not
that had anything to do with Semaphores, Mutexs, or just bad programming I
have no idea (but strongly suspect the latter. <g>).
Another issue to consider is that the 'mutex' provided by Win32Api isn't a
'real' kernel mutex; it is what the micro-geeks call a 'mutant', what ever
the heck that is. There is always about 5 to 12 layers of indirection
between here and there in VB.
It is hard to see how Windows would go about preserving a 'Mutex' if the
owning thread goes away. (In other words how would the OS *know* to close it
unless it is part of ending the thread?) So, is there such a thing as an
orphan thread in Windows? I don't know.
It gets damn complicated - After all, the whole process is amazing magic
when examined in depth - that is, it is hard enough to track what the heck
is going on when it all goes well - let alone know what happens when it
doesn't. <g>
-ralph
.
- Follow-Ups:
- References:
- Re: How to allow a specific number of Instances of my app?
- From: Ralph
- Re: How to allow a specific number of Instances of my app?
- From: Ralph
- Re: How to allow a specific number of Instances of my app?
- From: expvb
- Re: How to allow a specific number of Instances of my app?
- From: Ralph
- Re: How to allow a specific number of Instances of my app?
- From: expvb
- Re: How to allow a specific number of Instances of my app?
- Prev by Date: Re: [VB5 IDE] Support for CTRL-arrow for in-place scrolling?
- Next by Date: Re: Newbie help please
- Previous by thread: Re: How to allow a specific number of Instances of my app?
- Next by thread: Re: How to allow a specific number of Instances of my app?
- Index(es):
Relevant Pages
|