C# Links
Periodic Execution in .NET: This is the best implementation note I found of the common pattern to run tasks periodically.
TLDR version: use the ThreadPool.RegisterWaitForSingleObject()
function.
Implementing the Singleton Pattern in C#: I actually found singleton not all that useful. The article is a good discussion of many C# features nonetheless. TLDR version:
None lazy version code snippet:
public sealed class Singleton
{
private static readonly Singleton instance = new Singleton();
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit
static Singleton() {}
private Singleton() {}
public static Singleton Instance {get {return instance;}}
}
Lazy version code snippet: (requiring .NET 4 or above)
public sealed class Singleton
{
private static readonly Lazy<Singleton>
lazy = new Lazy<Singleton> (() => new Singleton());
public static Singleton Instance { get { return lazy.Value; } }
private Singleton() {}
}