Hi
I would like to implement a Systemwide singleton in .net. Is it sensible to
use a mutex for this? The application only can be run by one user at the
time. Does anyone have any articles/samples that can help me with this
problem?
thanks
N
Michael Nemtsev - 23 Apr 2007 09:10 GMT
Hello Nick,
Seems that u mix it up a liitle bit
Singleton allows you to create only one instance of the specific class: http://dofactory.com/Patterns/PatternSingleton.aspx
If you want to have to start the single copy of the application you need
to use global mutex: http://msdn2.microsoft.com/en-us/library/system.threading.mutex.aspx
---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
NC> would like to implement a Systemwide singleton in .net. Is it
NC> sensible to use a mutex for this? The application only can be run by
NC> one user at the time. Does anyone have any articles/samples that can
NC> help me with this problem?
NC>
Murdoc - 04 Jun 2007 22:12 GMT
> Hi
>
> I would like to implement a Systemwide singleton in .net. Is it sensible to use a mutex for this? > The application only can be run by one user at the time.
What exactly do you mean by this?
1. Only allow a single instance (regardless of the user) to be loaded per machine
2. Only a single instance can be running at a time regardless of the machine
3. Only allow a given user to be executing a single instance of your application on a given machine; or
4. Only allow a given user to be executing a single instance of your application, regardless of machine.
Only the first one is really achievable with a Mutex.
The other two would require some form of database record and/or control file to be used.
--