终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

31 lines
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. }