Re: [GD-Windows] Limiting to one instance
Brought to you by:
vexxed72
From: Alen L. <ale...@cr...> - 2006-08-16 07:40:35
|
Jon wrote: > Using FindWindow() introduces a possible race condition I stand corrected. I was using this for installers, not for actually preventing double-startup of the same app. So scratch my remark on FindWindow being useful here. Stefan wrote: > But CreateMutex etc *is* intended for the purpose. Well, I was replying to Andrew's comment on IP ports not being suitable for that purpose. In that context, I believe CreateMutex is not any more suitable. CreateMutex (named) is intended for the purpose of synchronizing two processes by actually using a mutex. Using the mutex's mere existance to note anything is as much of a hack as using an IP port for that. The fact that there are personal firewalls in the modern world is another hack as well. IP port creation was not supposed to be intercepted in this way - in the original design, AFAIK. Simply trying to point out the fact that we frequently have to use something for what it is not supposed to be used for. And often one can't predict all possible side-effects. Like that poor guy didn't predict that a firewall would make the IP-port solution useless, like FindWindow is not perfect due to a possible race condition, like the CreateMutex might have possible user-switching problem (although not likely, as local creation is default, IIRC). Put simply: unless the manual says "this can be used to do XYZ", then if you are using it for that, you are risking possible problems. (Although, you are probably risking possible problems even if it does say so. :p ) JM2C, Alen |