-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (47 loc) · 1.85 KB
/
Program.cs
File metadata and controls
53 lines (47 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Windows.Forms;
using System.Threading; // Necesario para Mutex
namespace ClearCacheIcons;
static class Program
{
private const string AppName = "ClearCacheIcons_AppMutex";
private static Mutex mutex = new Mutex(true, AppName);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (!mutex.WaitOne(TimeSpan.Zero, true))
{
// Si el mutex ya está tomado, significa que otra instancia está corriendo.
using (var form = new CustomMessageBoxForm("Clear Cache Icons ya se está ejecutando.", "Aplicación en ejecución"))
{
form.ShowDialog();
}
return;
}
try
{
Console.WriteLine("Application Main method started."); // Debug log
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); // Habilitar escalado DPI por monitor
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Console.WriteLine("Application.Run completed."); // Debug log
}
catch (Exception ex)
{
Console.WriteLine($"An unhandled exception occurred: {ex.Message}");
Console.WriteLine(ex.StackTrace);
MessageBox.Show($"An unhandled exception occurred: {ex.Message}\n\n{ex.StackTrace}", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
mutex.ReleaseMutex(); // Liberar el mutex al cerrar la aplicación
}
}
}