通过GUID确保winform运行唯一实例

通过程序生成的GUIDwinform唯一实例

using System.Threading;bool createdNew;
Guid ownGUID = new Guid(((GuidAttribute)Attribute.GetCustomAttribute(
Assembly.GetExecutingAssembly(),typeof(GuidAttribute))).Value);
Mutex instance = new Mutex(true, ownGUID.ToString("N"), out createdNew);
if (!createdNew) { MessageBox.Show("只能运行唯一实例"); return; }

  

posted on 2016-02-26 13:26  lucika.zh  阅读(568)  评论(0编辑  收藏  举报

导航