Singleton Pattern


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. # region Constructors
  2. private static volatile LogWorker current;
  3. private static object syncRoot = new Object();
  4.  
  5. private LogWorker()
  6. {
  7. }
  8.  
  9. public static LogWorker Current
  10. {
  11. get
  12. {
  13. if (current == null)
  14. {
  15. lock (syncRoot)
  16. {
  17. if (current == null)
  18. {
  19. current = new LogWorker();
  20. }
  21. }
  22. }
  23. return current;
  24. }
  25. }
  26. # endregion

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.