Files
mirror-processhacker/trunk/ProcessHacker/Common/Singleton.cs
T
wj32 aabd8ab7ce major directory and namespace refactoring
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1064 21ef857c-d57f-4fe0-8362-d861dc6d29cd
2009-04-15 08:20:18 +00:00

30 lines
703 B
C#

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