-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
29 lines (24 loc) · 1.18 KB
/
Program.cs
File metadata and controls
29 lines (24 loc) · 1.18 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
namespace ClaudeUsageMonitor;
internal static class Program
{
[STAThread]
static void Main()
{
using var mutex = new Mutex(true, "Local\\{a3f7c2d1-84e6-4b09-9f3a-2c1e7d508b4f}", out bool isNew);
if (!isNew) { MessageBox.Show("Already running.", "Claude Usage Monitor"); return; }
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
Application.ThreadException += (_, e) =>
MessageBox.Show($"An unexpected error occurred:\n\n{e.Exception.Message}",
"Claude Usage Monitor \u2013 Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
var logPath = Path.Combine(Path.GetTempPath(), "claude-usage-monitor-crash.log");
File.WriteAllText(logPath, $"{DateTime.Now:u}\n{e.ExceptionObject}");
MessageBox.Show($"A fatal error occurred. Details saved to:\n{logPath}",
"Claude Usage Monitor \u2013 Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
};
Application.Run(new MainForm());
}
}