c# - 使用 Mutex c#.net 打开/显示表单
问题描述
如果表单已经存在,有没有办法打开/显示表单?我使用 Mutex 来检查我的应用程序的实例是否打开。
这是我的 program.cs 文件的代码。
static void Main() {
bool InstanceCount = false;
using (Mutex m = new Mutex(true, "MyRunningApp", out InstanceCount)) {
if (InstanceCount) {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
m.ReleaseMutex();
}
else {
MessageBox.Show("Power Monitor is Already RUNNING, Please Check the System Tray.");
}
}
}
我试过 Show(); 但它给了我这个错误“当前上下文中不存在名称'show'”。
解决方案
推荐阅读
- git - 如何从 git 从 dev 中删除一个特定的合并
- pcl - 在多边形的正常空间内的 pcl 点云中查找点
- c# - Autocad .NET - 扩展命令行
- python - 将循环转换为 Java 中的矢量化计算
- android - 运行 Espresso 测试时 androidx.appcompat.app.AppCompatActivity 上的 ClassNotFoundException(启动应用程序工作正常)
- java - Quarkus 的依赖注入
- xsd - 自定义日期时间模式 XSD
- pine-script - 调试 pinescript 学习错误,负索引值
- python - IndexError:索引 748 超出轴 0 大小为 1 的范围(当我训练我的 CNN 时)
- c - C 宏应该在一个地方扩展为 char*,在另一个地方扩展为 wchar*,并使用 L 字符