Ejemplo n.º 1
0
 //Metodo de acceso publico para obtener la instancia
 public static LogfileSingleton GetInstance(string fileName)
 {
     if (_instance == null)
     {
         _instance = new LogfileSingleton(fileName);
     }
     return(_instance);
 }
Ejemplo n.º 2
0
        public static void WriteLogSingleton()
        {
            Console.Clear();
            Console.WriteLine("WriteLogSingleton");
            LogfileSingleton log1 = LogfileSingleton.GetInstance(_fileName);
            LogfileSingleton log2 = LogfileSingleton.GetInstance(_fileName);

            log1.SaveMessage(LogType.Error, "Error 1");
            log1.SaveMessage(LogType.System, "System 1");
            log1.SaveMessage(LogType.Warning, "Warning 1");
            log2.SaveMessage(LogType.Error, "Error 2");
            log2.SaveMessage(LogType.System, "System 2");
            log2.SaveMessage(LogType.Warning, "Warning 2");
            Wait();
        }