惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
A
About on SuperTechFans
GbyAI
GbyAI
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 【当耐特】
博客园 - 司徒正美
博客园 - 聂微东
P
Proofpoint News Feed
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
B
Blog RSS Feed
Jina AI
Jina AI
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
博客园 - 叶小钗

博客园 - Heclei

WebDeploy 同步IIS6 bindingRedirect 相当奇怪的设置 - Heclei - 博客园 C# 使用WM_NCLBUTTONDOWN消息实现任意位置移动窗体 发布开源程序:数据库结构比较 VS2005 WEB F5调试自动退出调试状态 JS整理,getCookie, getElementsByClassName , 添加删除事件 (转)VC++ 2005 用程式建立 Paradox ( *.db ) 资料库档桉 - Heclei C# 判断操作系统类型 Service Broker实现发布-订阅(Publish-Subscribe)框架(3) Service Broker实现发布-订阅(Publish-Subscribe)框架(2) Service Broker实现发布-订阅(Publish-Subscribe)框架(1) .net sqlserver 关于连接池没事释放的注意项 mysql ERROR 1045 JS实现局部打印和预览 perforce,P4,权限设置 Visual Studio 2005 sp1 新愁加就恨 将一个数据库的登录账户转移到另一个账户中(Trans logins from one database to another ) Find the need for WinFx, understanding for very very beginners 使用vsto制作的outlook插件,安装加载失败
(转)C# 单实例 - Heclei - 博客园
Heclei · 2009-03-13 · via 博客园 - Heclei

 static private bool IsOneInstance()
        {
#if !DEBUG
            bool one;
            mutex = new System.Threading.Mutex(true, "VIPSHOP", out one);
            return one;
#else
            return true;
#endif
        }

            if (IsOneInstance())
            {
                Application.Run(new LoginFrm());
            }
            else
            {
                MessageBox.Show("只允许运行一个实例", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

在Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

释放mutex

if (mutex != null)
            {
                mutex.ReleaseMutex();
                mutex.Close();
            }