mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
aabd8ab7ce
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@1064 21ef857c-d57f-4fe0-8362-d861dc6d29cd
30 lines
703 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|