using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
namespace RunOnce
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
bool createNew = false;
using (new Semaphore(0, 1, "MyAppIdentify", out createNew))
{
if (createNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("已经有程序在运行!");
}
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
namespace RunOnce
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
bool createNew = false;
using (new Semaphore(0, 1, "MyAppIdentify", out createNew))
{
if (createNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
else
{
MessageBox.Show("已经有程序在运行!");
}
}
}
}
}