Re: [GD-Windows] Limiting to one instance
Brought to you by:
vexxed72
From: Chris C. <can...@gm...> - 2006-08-16 09:14:22
|
It would seem like a combination of the two approachs avoids the drawbacks of either, no? Use a named mutex to protect the initialisation process, so that if FindWindow fails to find an existing window, the mutex is held until after the window is created. In a switch user case, the window will have long since been created, and so the mutex won't be held open. The logic becomes "no two users can start the application" rather than "no two users can run the application". Personally I've always used the named mutex alone to protect the app, and found it to be stable and robust; but I've never had to write a shipping PC title or deal with limited user cases... C Black Company Studios On 16/08/06, Richard Mitton <mi...@tr...> wrote: > > http://support.microsoft.com/default.aspx?scid=kb;en-us;106385 > > I guess it is an officially recommended technique. > A mutex is a proper kernel object, so should be pretty safe. > > -- > ()() Richard Mitton > ( '.') > (")_(") code jester .:. treyarch .:. mi...@tr... > > > > > On 16 Aug 2006, at 12:37 am, Alen Ladavac wrote: > > > 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 > > > > > > ---------------------------------------------------------------------- > > --- > > Using Tomcat but need to do more? Need to support web services, > > security? > > Get stuff done quickly with pre-integrated technology to make your > > job easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > > Geronimo > > http://sel.as-us.falkag.net/sel? > > cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > Gamedevlists-windows mailing list > > Gam...@li... > > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > > Archives: > > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |