using SteamWare.IO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LPA
{
static class Program
{
///
/// Mutex x evitare multiple instances
///
static Mutex _m;
static bool IsSingleInstance()
{
try
{
// Try to open existing mutex.
_ = Mutex.OpenExisting("SteamwareLPA");
}
catch
{
// If exception occurred, there is no such mutex.
Program._m = new Mutex(true, "SteamwareLPA");
// Only one instance.
return true;
}
// More than one instance.
return false;
}
///
/// Punto di ingresso principale dell'applicazione.
///
[STAThread]
static void Main()
{
bool enableStartup = true;
// se abilitato il controllo istanza (solo 1...)
if (memLayer.ML.CRB("singleInstance"))
{
utils.lgInfo("Single instance only: checking!");
if (!Program.IsSingleInstance())
{
utils.lgInfo("More than one instance found: exiting");
enableStartup = false;
}
else
{
// Continue with program.
Console.WriteLine("OK! only One instance running");
}
}
else
{
utils.lgInfo("Multiple instance allowed: check not requested");
}
// se abilitato procedo
if (enableStartup)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}
}