Per essere sicuri si eseguire una singola istanza di un applicazione C# potete scrivere il seguente codice:
//C#
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
namespace ProvaCSharp
{
static class Program
{
private static Mutex mutex;
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
mutex = new Mutex( true, Application.ProductName );
if (mutex.WaitOne(0, false))
{
Application.Run(new Form1());
}
else
{
MessageBox.Show(Application.ProductName + " è già in esecuzione");
}
}
}
}
Nessun commento:
Posta un commento