当前位置: 首页> 房产> 建材 > 网上国网app推广效果_企业公司有哪些_百度不收录网站_如何做网络推广人员

网上国网app推广效果_企业公司有哪些_百度不收录网站_如何做网络推广人员

时间:2025/7/9 17:45:46来源:https://blog.csdn.net/u014584014/article/details/145909789 浏览次数:0次
网上国网app推广效果_企业公司有哪些_百度不收录网站_如何做网络推广人员

常规需求 C#程序只能运行一次,不能多开:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.Security.Principal;
namespace BallLocation
{static class Program{[STAThread]static void Main(){ bool createNew;using (Mutex mutex = new Mutex(true, Application.ProductName, out createNew)){if (createNew){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new MainForm());//这里是 winform的入口}else{MessageBox.Show("程序已经在运行,请不要重复打开!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}	}}
}

            //使用System.Threading.Mutex来确保程序只有一个实例运行
            //Application.ProductName可能不是最佳选择,因为它依赖于Application类的初始化
            //建议使用一个固定的字符串作为互斥体名称

		   bool createNew;using (Mutex mutex = new Mutex(true, "Global\\BallLocationMutex", out createNew)){if (createNew){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new MainForm());}else{// 如果程序已经在运行,提示用户MessageBox.Show("程序已经在运行,请不要重复打开!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);}}
//----------
string currentDirectory = Environment.CurrentDirectory;
Console.WriteLine("当前工作目录: " + currentDirectory);

关键字:网上国网app推广效果_企业公司有哪些_百度不收录网站_如何做网络推广人员

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: