Files
mirror-processhacker/trunk/ProcessHacker/Singleton.cs
T
wj32 a46b5836b6 extended Actions to services
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@965 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-03-29 09:35:57 +00:00

30 lines
682 B
C#

namespace ProcessHacker
{
/// <summary>
/// Implements the singleton pattern.
/// </summary>
public class Singleton<T>
where T : class, new()
{
private object _instanceLock = new object();
private T _instance = null;
/// <summary>
/// The single instance of the type.
/// </summary>
public T Instance
{
get
{
lock (_instanceLock)
{
if (_instance == null)
_instance = new T();
return _instance;
}
}
}
}
}