namespace TestWinApp
{
public partial class Form1 : Form
{
public static int count = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
bool result;
var mutex = new System.Threading.Mutex(true, "UniqueAppId", out result);
if (!result)
{
MessageBox.Show("Another user is already running.");
return;
}
//Application.Run(new Form1());
GC.KeepAlive(mutex);
}
}
}
{
public partial class Form1 : Form
{
public static int count = 0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
bool result;
var mutex = new System.Threading.Mutex(true, "UniqueAppId", out result);
if (!result)
{
MessageBox.Show("Another user is already running.");
return;
}
//Application.Run(new Form1());
GC.KeepAlive(mutex);
}
}
}