Пример #1
0
        static void Main(string[] args)
        {
            #region ThreadSave
            var           logger    = ThreadSafeLoggerSingleton.GetInstance();
            HardProcessor proccesso = new HardProcessor(1);
            logger.Log("Hard work started...");
            proccesso.ProcessTo(5);

            Thread.Sleep(1000);

            logger.Log("Hard work finished...");
            Console.ReadKey();
            #endregion

            //var logger = LoggerSingleton.GetInstance();
            //HardProcessor proccessor = new HardProcessor(1);
            //logger.Log("Hard work started...");
            //proccessor.ProcessTo(5);

            //Thread.Sleep(1000);

            //logger.Log("Hard work finished...");

            //Console.ReadKey();
        }
Пример #2
0
 public static ThreadSafeLoggerSingleton GetInstance()
 {
     lock (locker)
     {
         return(_loggerInstance ?? (_loggerInstance = new ThreadSafeLoggerSingleton()));
     }
 }