搭建自己的直播平台,实现exe单例模式
搭建自己的直播平台,实现exe单例模式的相关代码
static void Main()
{undefined
Application.EnableVisualStyles(); //样式设置
Application.SetCompatibleTextRenderingDefault(false); //样式设置
//获取当前进程名称
string currentProcessName = Process.GetCurrentProcess().ProcessName;
//把该名称的所有进程的列表
Process[] process = Process.GetProcessesByName(currentProcessName);
if (process.Length > 1)
{undefined
MessageBox.Show("程序已经运行!", " 提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
FormSplash sp = new FormSplash(); //启动窗体
sp.pictureBox1.SendToBack();
sp.Show(); //显示启动窗体
context = new ApplicationContext();
context.Tag = sp;
Application.Idle += new EventHandler(Application_Idle); //注册程序运行空闲去执行主程序窗体相应初始化代码
Application.Run(context);
}
以上就是 搭建自己的直播平台,实现exe单例模式的相关代码,更多内容欢迎关注之后的文章