终端一体化运控平台
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

31 líneas
744 B

  1. using System;
  2. /* ***********************************************
  3.  * subject 单例对象基类
  4.  * author 张原川
  5.  * date   2019/6/3 9:49:03
  6.  * ***********************************************/
  7. namespace BPASmartClient.Helper
  8. {
  9. /// <summary>
  10. /// 单例对象基类
  11. /// </summary>
  12. /// <typeparam name="T"></typeparam>
  13. public class Singleton<T> where T : new()
  14. {
  15. private static object _async = new object();
  16. private static T _instance;
  17. static readonly Lazy<T> instance = new();
  18. /// <summary>
  19. /// 获取实例
  20. /// </summary>
  21. /// <returns></returns>
  22. public static T GetInstance()
  23. {
  24. return instance.Value;
  25. }
  26. }
  27. }