// ReSharper disable InconsistentNaming private static void Main(string[] args) // ReSharper restore InconsistentNaming { #if !DEBUG AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; #endif AppDomain.CurrentDomain.AssemblyResolve += _AssemblyResolver; COSFunctions.AddEnvironmentPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs\\unmanaged\\")); #if ARCH_X86 COSFunctions.AddEnvironmentPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs\\unmanaged\\x86\\")); #endif #if ARCH_X64 COSFunctions.AddEnvironmentPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "libs\\unmanaged\\x64\\")); #endif // Close program if there is another instance running if (!_EnsureSingleInstance()) { return; } #if !DEBUG try { _Run(args); } catch (Exception e) { CLog.Fatal(e, "Unhandled error: {ErrorMessage}", CLog.Params(e.Message)); } #else _Run(args); #endif _CloseProgram(); }
public static void Init() { #if ARCH_X86 string path = "x86"; #endif #if ARCH_X64 string path = "x64"; #endif path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + path; COSFunctions.AddEnvironmentPath(path); #if LINUX _EnsureDataFolderExists(); #endif }
private static bool _EnsureSingleInstance() { // wait a few seconds in case that the instance is just shutting down if (!_Mutex.WaitOne(TimeSpan.FromSeconds(2), false)) { //TODO: put it into language file MessageBox.Show("Another Instance of Vocaluxe is already runnning!"); #if WIN Process currentProcess = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); foreach (Process process in processes.Where(t => t.Id != currentProcess.Id)) { IntPtr wnd = process.MainWindowHandle; if (wnd != IntPtr.Zero) { COSFunctions.SetForegroundWindow(wnd); } } #endif return(false); } return(true); }