Programando un rato para el Intellekt.Code.Framework, tuve que utilizar un Singleton. Aquí les dejo el código para que vean lo sencillo que es implementarlo en C#:
| 1 | using System; | 
| 2 | |
| 3 | public sealed class Singleton | 
| 4 | { | 
| 5 | private static volatile Singleton instance; | 
| 6 | private static object syncRoot = new Object(); | 
| 7 | |
| 8 | private Singleton() {} | 
| 9 | |
| 10 | public static Singleton Instance | 
| 11 | { | 
| 12 | get | 
| 13 | { | 
| 14 | if (instance == null) | 
| 15 | { | 
| 16 | lock (syncRoot) | 
| 17 | { | 
| 18 | if (instance == null) | 
| 19 | instance = new Singleton(); | 
| 20 | } | 
| 21 | } | 
| 22 | |
| 23 | return instance; | 
| 24 | } | 
| 25 | } | 
| 26 | } | 
Este código está basado en Microsoft Patterns, ahi podrian encontrar el artículo completo.
Cheers!
