AppUnique.cs 919 B

12345678910111213141516171819202122232425262728
  1. //************************************************************************
  2. // https://github.com/yuzhengyang
  3. // author: yuzhengyang
  4. // date: 2017.10.12 - 2017.10.12
  5. // desc: App唯一启动工具
  6. // Copyright (c) yuzhengyang. All rights reserved.
  7. //************************************************************************
  8. using System.Threading;
  9. namespace Azylee.Core.AppUtils
  10. {
  11. public sealed class AppUnique
  12. {
  13. private Mutex Mutex { get; set; }
  14. /// <summary>
  15. /// 判断应用在当前系统实例下是否唯一(搭配 ApplicationAPI.Raise() 食用更佳)
  16. /// </summary>
  17. /// <param name="appName"></param>
  18. /// <returns></returns>
  19. public bool IsUnique(string appName)
  20. {
  21. bool unique;
  22. Mutex = new Mutex(true, appName, out unique);
  23. return unique;
  24. }
  25. }
  26. }