Skip to content

Instantly share code, notes, and snippets.

@kellyelton
Created November 4, 2013 19:18
Show Gist options
  • Select an option

  • Save kellyelton/7307752 to your computer and use it in GitHub Desktop.

Select an option

Save kellyelton/7307752 to your computer and use it in GitHub Desktop.
SingletonTemplate
#region Singleton
internal static $name$ SingletonContext { get; set; }
private static readonly object $name$SingletonLocker = new object();
public static $name$ Instance
{
get
{
if (SingletonContext == null)
{
lock ($name$SingletonLocker)
{
if (SingletonContext == null)
{
SingletonContext = new $name$();
}
}
}
return SingletonContext;
}
}
#endregion Singleton
$END$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment